It turns out _getpid (https://msdn.microsoft.com/en-us/library/t2y34y40.aspx) actually calls GetCurrentProcessId (https://msdn.microsoft.com/en-us/library/windows/desktop/ms683180(v=vs.85).aspx).
I created small test binary and added a breakpoint for GetCurrentProcessId. bm KERNEL32!GetCurrentProcessId 0:000> k # Child-SP RetAddr Call Site 00 000000e2`5054fbb8 00007ffa`7efe056a KERNEL32!GetCurrentProcessId 01 000000e2`5054fbc0 00007ff6`0edc1037 MSVCR120D!getpid+0xa 02 000000e2`5054fbf0 00007ff6`0edc13ad ConsoleApplication10!wmain+0x27 0:000> bl 1 e 00007ffa`9f771e70 0001 (0001) 0:**** KERNEL32!GetCurrentProcessId IMO this should guarantee the result of GetCurrentProcessId to an int is ok. I'll respin the patches using the inline function as you suggested Ben. I'll also add you as co-author and add a caveat on top (so we remember about it). Thanks, Alin. > -----Original Message----- > From: [email protected] [mailto:ovs-dev- > [email protected]] On Behalf Of Alin Serdean > Sent: Wednesday, April 19, 2017 8:03 AM > To: Ben Pfaff <[email protected]> > Cc: [email protected] > Subject: Re: [ovs-dev] [PATCH 02/10] windows: add definition of getpid and > getcwd > > The documentation is somewhat unclear on it. I'll try to expand > getpid/GetCurrentProcessId to see if they call the same things under the > scenes (one would assume yes), and let you know. > > Thanks, > Alin. > > > -----Original Message----- > > From: Ben Pfaff [mailto:[email protected]] > > Sent: Wednesday, April 19, 2017 7:55 AM > > To: Alin Serdean <[email protected]> > > Cc: Sairam Venugopal <[email protected]>; [email protected] > > Subject: Re: [ovs-dev] [PATCH 02/10] windows: add definition of getpid > > and getcwd > > > > I don't know how much risk there is. If the values actually returned > > in practice as process IDs by GetCurrentProcessId() are all in the > > range 0...INT_MAX, then it's fine to use the implementation I > > suggested. But if it might return any value, then it is safer to use > > _getpid(). > > _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
