This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [patch] Building simulators on windows hosts
- From: Christopher Faylor <me at cgf dot cx>
- To: gdb-patches at sources dot redhat dot com,Paul Brook <paul at codesourcery dot com>, Eli Zaretskii <eliz at gnu dot org>
- Date: Sun, 1 May 2005 00:42:48 -0400
- Subject: Re: [patch] Building simulators on windows hosts
- References: <200504291539.15275.paul@codesourcery.com> <01c54dff$Blat.v2.4$ea33f500@zahav.net.il>
On Sun, May 01, 2005 at 06:42:10AM +0300, Eli Zaretskii wrote:
>> From: Paul Brook <paul@codesourcery.com>
>> Date: Fri, 29 Apr 2005 15:39:15 +0100
>>
>> +#ifdef HAVE_LSTAT
>> return wrap (p, lstat (file, buf));
>> +#else
>> + return wrap (p, stat (file, buf));
>> +#endif
>
>Wouldn't it be cleaner to say in some strategic place (like a header
>included by many sim files)
>
> #ifndef HAVE_LSTAT
> #define lstat stat
> #endif
>
>and then leave the *.c files alone? I think this is a better
>solution, and include/gdb/callback.h seems like a good place to do
>that.
>
>Perhaps it's even something MinGW headers should do for you, but for
>now a GDB solution will be fine.
I agree with the above. Sprinkling ifdefs for things like this in the
code is really not pretty.
>> +#ifdef HAVE_FTRUNCATE
>> result = wrap (p, ftruncate (fdmap (p, fd), len));
>> +#else
>> + p->last_errno = EINVAL;
>> + result = -1;
>> +#endif
>> return result;
>
>`ftruncate' is a very simple function; you could write an emulation
>using `lseek' and `write'. (If you want, I can show you the
>implementation from the DJGPP library.) I think it's better to add
>such an emulation that to fail the calls.
FWIW, the windows equivalent of 'ftruncate' is more-or-less 'SetEndOfFile'.
It should be pretty easy to write an emulation of ftruncate using that.
cgf