Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com Date: Mon, 18 Jun 2001 00:50:47 +0200 From: Corinna Vinschen To: cygwin-developers AT cygwin DOT com Subject: Re: [LONG MAIL]: The story of the tiny TAPE_GET_MEDIA_PARAMETERS searching the man in the moon Message-ID: <20010618005047.E5033@cobold.vinschen.de> Reply-To: cygdev Mail-Followup-To: cygwin-developers AT cygwin DOT com References: <20010615123907 DOT C324 AT cygbert DOT vinschen DOT de> <20010615110027 DOT B15095 AT redhat DOT com> <20010615171439 DOT M324 AT cygbert DOT vinschen DOT de> <20010615111627 DOT D15179 AT redhat DOT com> <20010615181008 DOT N324 AT cygbert DOT vinschen DOT de> <20010615121316 DOT A15646 AT redhat DOT com> <3B2A7E1F DOT 1CE1D3D0 AT yahoo DOT com> <20010615204318 DOT D31488 AT redhat DOT com> <3B2AB5EE DOT D6855F4A AT yahoo DOT com> <20010615220227 DOT A509 AT redhat DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.12i In-Reply-To: <20010615220227.A509@redhat.com>; from cgf@redhat.com on Fri, Jun 15, 2001 at 10:02:27PM -0400 On Fri, Jun 15, 2001 at 10:02:27PM -0400, Christopher Faylor wrote: > On Fri, Jun 15, 2001 at 09:27:10PM -0400, Earnie Boyd wrote: > >Christopher Faylor wrote: > >> The problem is apparently that the native gcc compiler and a cross > >> compiler seem to disagree on default structure packing. > > > >Perhaps the -fnative-struct patch should be interesting to help? > > Perhaps, but the reason I forwarded it here is because I'm swamped and > don't have time for much investigation in strange (gcc) code. > > The theory is that someone in this cooperative project might be interested > in helping out. > > I'd hoped that Corinna would provide more details. She should be back online > on Monday. Maybe we'll hear from her then. I only can repeat the mail I originally sent to Chris. I actually tried to debug gcc on Friday but I don't know too much about gcc and I didn't find anything obvious in an hour or so. Nevertheless, I was a somewhat busy with my travel preparations on Friday. Ok, the original mail I sent to Chris so everyone can see at least the result of the problem: ============= SNIP ============= To get info on tapes, the fhandler_tape code calls TapeGetParameters() that way: TAPE_GET_MEDIA_PARAMETERS mp; DWORD len; len = sizeof mp; TapeGetParameters(..., &len, &mp); len is an in/out parameter. It should be preloaded with the buffer size on input and contains the correct required buffersize after the call. The above call failed which surprised me REALLY since the code is over a year old and I was pretty sure that it worked before. I added debug output and found that sizeof mp is returned as 28 while len contains 32 as required buffersize after the call. Interesting enough, the buffersize for the second possible buffer type (TAPE_GET_DRIVE_PARAMETERS) is 32. I changed the sizeof so that it's set to 32 and now it worked. I checked in the change and that could be the end of the story but it isn't. Actually I checked the code of my `mt' implementation if I already had done the same there. mt isn't using the ioctl interface of Cygwin but instead uses native WinNT calls since mt is older than the changes to Cygwin. Surprisingly enough I found that I had used the same `sizeof mp' there. What was going on here? Why does that work in `mt' but not in the DLL? I was already suspecting some conspiracy (FBI, Aliens...). I compiled mt again and it still worked... uhm... ok, now I saw the difference. The DLL is cross compiled while mt was compiled natively. The same structure TAPE_GET_MEDIA_PARAMETERS has a size of 28 bytes when cross compiled, while it is (correctly) 32 bytes when compiled natively. I checked that I really used the same winnt.h file in both cases. As I already mentioned I'm using the tier1-00r1p2 for cross compiling. And since that problem already exists in 1.3.2, I suspect that your compiler which you're using for building Cygwin has the same problem. At least the current native gcc-2.95.3 doesn't have it. Otherwise mt would have used the same wrong value of 28. The difference is only explainable by the pack algorithm. The cross compiler uses a default structure packing of 4 Bytes and the native gcc a default packing of 8 Bytes, probably. ============= SNAP ============= Just a guess: Perhaps, the cross compiler uses the packing algorithm of the HOST instead of the TARGET. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Developer mailto:cygwin AT cygwin DOT com Red Hat, Inc.