From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=48436 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PwMEJ-00053y-4z for qemu-devel@nongnu.org; Sun, 06 Mar 2011 17:15:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PwMED-0001Ej-J3 for qemu-devel@nongnu.org; Sun, 06 Mar 2011 17:15:10 -0500 Received: from moutng.kundenserver.de ([212.227.17.10]:56712) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PwMED-0001E9-4e for qemu-devel@nongnu.org; Sun, 06 Mar 2011 17:15:05 -0500 Message-ID: <4D740764.8060606@mail.berlios.de> Date: Sun, 06 Mar 2011 23:15:00 +0100 From: Stefan Weil MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 2/3] w32: Add macro timersub to sys/time.h References: <1298829142-5550-1-git-send-email-weil@mail.berlios.de> <1298829142-5550-2-git-send-email-weil@mail.berlios.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: qemu-devel@nongnu.org Am 05.03.2011 10:34, schrieb Blue Swirl: > On Sun, Feb 27, 2011 at 7:52 PM, Stefan Weil wrote: >> timersub is needed by the latest vnc code. >> >> Signed-off-by: Stefan Weil >> --- >> hosts/w32/include/sys/time.h | 24 ++++++++++++++++++++++++ >> 1 files changed, 24 insertions(+), 0 deletions(-) >> create mode 100644 hosts/w32/include/sys/time.h >> >> diff --git a/hosts/w32/include/sys/time.h b/hosts/w32/include/sys/time.h >> new file mode 100644 >> index 0000000..94056ff >> --- /dev/null >> +++ b/hosts/w32/include/sys/time.h > > Nack. The QEMU way of handling host peculiarities is to add wrappers, > for example qemu_timersub in this case, and converting all callers. That's one way how things can be handled. I know at least one QEMU maintainer who does not like those workarounds, especially if they are needed because of w32/w64 operating systems, so I decided to choose a different approach here. My approach also can be easily removed as soon as MinGW is improved (I'm sure it will be improved). There is another QEMU way of handling host peculiarities: conditional compilation. Most of this kind of handling could be eliminated by my approach. > >> @@ -0,0 +1,24 @@ >> +/* >> + * Extensions of MinGW sys/time.h >> + * >> + * Copyright (C) 2011 Stefan Weil >> + * >> + * This work is licensed under the terms of the GNU LGPL, version >> 2.1 or later. >> + * See the COPYING.LIB file in the top-level directory. >> + * >> + */ >> + >> +#include_next > > Isn't include_next an extension by GCC? It is, but that's not critical given the fact that QEMU does not work without gcc. If needed, this dependency can be fixed easily by renaming the intermediate include files (and including the renamed files). I don't think that those intermediate files will be needed forever, so a clean and cheap solution like the one which I implemented seems to be more important to me. > >> + >> +#ifndef timersub >> +/* This is a copy from GNU C Library (GNU LGPL 2.1), sys/time.h. */ >> +# define timersub(a, b, result) >> \ >> + do { >> \ >> + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; >> \ >> + (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; >> \ >> + if ((result)->tv_usec < 0) { >> \ >> + --(result)->tv_sec; >> \ >> + (result)->tv_usec += 1000000; >> \ >> + } >> \ >> + } while (0) >> +#endif >> -- >> 1.7.2.3 By the way: it's not possible to add timersub to existing files like oslib-win32.c or os-win32.c (another way to handle the problem) because of incompatible licenses. Regards, Stefan W.