Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YPFOU-00044J-9D for pgsql-bugs@arkaria.postgresql.org; Sat, 21 Feb 2015 19:07:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YPFOT-0004qg-3s for pgsql-bugs@arkaria.postgresql.org; Sat, 21 Feb 2015 19:07:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YPFOR-0004qZ-UZ for pgsql-bugs@postgresql.org; Sat, 21 Feb 2015 19:07:12 +0000 Received: from mail-wg0-x236.google.com ([2a00:1450:400c:c00::236]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YPFOK-00049e-AY for pgsql-bugs@postgresql.org; Sat, 21 Feb 2015 19:07:10 +0000 Received: by mail-wg0-f54.google.com with SMTP id y19so18630015wgg.13 for ; Sat, 21 Feb 2015 11:07:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=07pNOeBNLiq2WjaT1tENFXWOQ5vlZ9q2JZBV1GBjV9s=; b=Ki7ZnILGdRxxuu6oWoUTaxIC5bVepgwQIamuQhG/xx8xpH5yVzZmBH7omrwsQA9kMC wAtDY3/bYwTTpfzKDmoW+Ra9cfXfW2WkgvmHLmUA/vIoroYAaUFDhT7EbgH8kL+aNS8f CXUrkbq4vSg7hFgL+EkOuOPuVwqcVh0N/UyDwcO77eCN2dozOSShM+8thvYsW8i2NHax M7KWXQrW3tH5r+6Caz1vnXuWBwyb92wB9JRDMUx6Lu2E23igOpsEK4ogXX+AirkQ6/eN FVk9BWKSDiABdjQ+DxeemrCxKHuswCcXac7YxlnkDeDbX1BDyz1sf6zwHj2wIJMY/CnN 8K9w== MIME-Version: 1.0 X-Received: by 10.194.122.38 with SMTP id lp6mr7384348wjb.24.1424545622512; Sat, 21 Feb 2015 11:07:02 -0800 (PST) Received: by 10.27.95.29 with HTTP; Sat, 21 Feb 2015 11:07:02 -0800 (PST) In-Reply-To: References: <20150212125412.GA9449@alap3.anarazel.de> <20150212131316.GB9449@alap3.anarazel.de> <20150212151403.GJ3391@alvh.no-ip.org> <20150212175305.GD9449@alap3.anarazel.de> Date: Sun, 22 Feb 2015 00:07:02 +0500 Message-ID: Subject: Re: gettimeofday cause crash on Windows From: Asif Naeem To: Robert Haas Cc: Michael Paquier , Andres Freund , Alvaro Herrera , "pgsql-bugs@postgresql.org" Content-Type: multipart/alternative; boundary=089e01227ee4cbd8cf050f9ddf77 X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --089e01227ee4cbd8cf050f9ddf77 Content-Type: text/plain; charset=UTF-8 Thank you Robert. I have built latest source code (master branch) with MSVC 2013, it seem working fine i.e. Build succeeded. > 0 Warning(s) > 0 Error(s) I will try to mimic currawong environment (MSVC 2008) to reproduce the issue. Thanks. On Sat, Feb 21, 2015 at 11:59 PM, Robert Haas wrote: > On Sat, Feb 21, 2015 at 1:00 PM, Robert Haas > wrote: > > On Sat, Feb 21, 2015 at 12:20 PM, Robert Haas > wrote: > >> On Thu, Feb 12, 2015 at 9:59 PM, Michael Paquier > >> wrote: > >>> I looked at your patch and tested it with msvc and it looks good to me. > >> > >> Committed with cosmetic adjustments. Hopefully one of you fine > >> gentlemen will jump in to help if this turns out to break, because I > >> don't do Windows. > > > > currawong doesn't like this: > > > > "c:\prog\bf\root\HEAD\pgsql.build\pgsql.sln" (default target) (1) -> > > (postgres target) -> > > .\src\port\gettimeofday.c(53): error C2440: 'initializing' : cannot > > convert from 'void (__cdecl *)(LPFILETIME)' to 'PgGetSystemTimeFn' > > > > > > "c:\prog\bf\root\HEAD\pgsql.build\pgsql.sln" (default target) (1) -> > > (misc\libpgport target) -> > > .\src\port\gettimeofday.c(53): error C2440: 'initializing' : cannot > > convert from 'void (__cdecl *)(LPFILETIME)' to 'PgGetSystemTimeFn' > > > > 0 Warning(s) > > 2 Error(s) > > I assume that the problem here must be whatever secret sauce WINAPI > pours on the declaration. PgSystemTimeFn is declared like this: > > typedef VOID (WINAPI *PgGetSystemTimeFn)(LPFILETIME); > > ...and the function we're trying to assign to a variable of that type > is declared like this: > > static void init_gettimeofday(LPFILETIME lpSystemTimeAsFileTime); > > Either "void" does not mean the same thing as "VOID", which would be > exceedingly evil, or the WINAPI in there matters, which is still evil, > but somewhat more understandable. > > -- > Robert Haas > EnterpriseDB: http://www.enterprisedb.com > The Enterprise PostgreSQL Company > --089e01227ee4cbd8cf050f9ddf77 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thank you Robert. I have built latest source code (master = branch) with MSVC 2013, it seem working fine i.e.

= Build succeeded.
=C2=A0 =C2=A0 0 Warning(s)
=C2=A0 =C2=A0 0 Error(s)<= /blockquote>

I will try to mimic=C2=A0currawong environm= ent (MSVC 2008) to reproduce the issue. Thanks.
=C2=A0

On Sat, Feb 21, = 2015 at 11:59 PM, Robert Haas <robertmhaas@gmail.com> wr= ote:
On Sat, Feb 21, 2015 at 1:00 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Sat, Feb 21, 2015 at 12:20 PM, Robert Haas <robertmhaas@gmail.com> wrote:
>> On Thu, Feb 12, 2015 at 9:59 PM, Michael Paquier
>> <michael.paquier@g= mail.com> wrote:
>>> I looked at your patch and tested it with msvc and it looks go= od to me.
>>
>> Committed with cosmetic adjustments.=C2=A0 Hopefully one of you fi= ne
>> gentlemen will jump in to help if this turns out to break, because= I
>> don't do Windows.
>
> currawong doesn't like this:
>
> "c:\prog\bf\root\HEAD\pgsql.build\pgsql.sln" (default target= ) (1) ->
> (postgres target) ->
>=C2=A0 =C2=A0.\src\port\gettimeofday.c(53): error C2440: 'initializ= ing' : cannot
> convert from 'void (__cdecl *)(LPFILETIME)' to 'PgGetSyste= mTimeFn'
>
>
> "c:\prog\bf\root\HEAD\pgsql.build\pgsql.sln" (default target= ) (1) ->
> (misc\libpgport target) ->
>=C2=A0 =C2=A0.\src\port\gettimeofday.c(53): error C2440: 'initializ= ing' : cannot
> convert from 'void (__cdecl *)(LPFILETIME)' to 'PgGetSyste= mTimeFn'
>
>=C2=A0 =C2=A0 =C2=A00 Warning(s)
>=C2=A0 =C2=A0 =C2=A02 Error(s)

I assume that the problem here must be whatever secret sauce WI= NAPI
pours on the declaration.=C2=A0 PgSystemTimeFn is declared like this:

typedef VOID (WINAPI *PgGetSystemTimeFn)(LPFILETIME);

...and the function we're trying to assign to a variable of that type is declared like this:

static void init_gettimeofday(LPFILETIME lpSystemTimeAsFileTime);

Either "void" does not mean the same thing as "VOID", w= hich would be
exceedingly evil, or the WINAPI in there matters, which is still evil,
but somewhat more understandable.

--
Robert Haas
EnterpriseDB: htt= p://www.enterprisedb.com
The Enterprise PostgreSQL Company

--089e01227ee4cbd8cf050f9ddf77--