Re: [ovs-dev] [PATCH 02/10] windows: add definition of getpid and getcwd

2017-04-18 Thread Alin Serdean
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:b...@ovn.org]
> Sent: Wednesday, April 19, 2017 7:55 AM
> To: Alin Serdean <aserd...@cloudbasesolutions.com>
> Cc: Sairam Venugopal <vsai...@vmware.com>; d...@openvswitch.org
> 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().
> 
> On Wed, Apr 19, 2017 at 03:31:13AM +, Alin Serdean wrote:
> > To bring more to the table:
> > From includes
> > typedef unsigned long   DWORD;
> > Our pid_t is defined:
> >
> https://github.com/openvswitch/ovs/blob/master/include/windows/windef
> s
> > .h#L41
> >
> > I'm wondering if it would be best not to cut corners on this one and just
> stick to _getpid and do the same thing as we already have for `string.h`.
> >
> > What do you think?
> >
> > Thanks,
> > Alin.
> > > -Original Message-
> > > From: Ben Pfaff [mailto:b...@ovn.org]
> > > Sent: Saturday, April 15, 2017 6:27 AM
> > > To: Sairam Venugopal <vsai...@vmware.com>
> > > Cc: Alin Serdean <aserd...@cloudbasesolutions.com>;
> > > d...@openvswitch.org
> > > Subject: Re: [ovs-dev] [PATCH 02/10] windows: add definition of
> > > getpid and getcwd
> > >
> > > If GetCurrentProcessId() is a reasonable substitute for getpid(),
> > > but the return type is different, then I would suggest an inline function,
> like this:
> > >
> > > static inline pid_t
> > > getpid(void)
> > > {
> > > return GetCurrentProcessId();
> > > }
> > >
> > > Thanks,
> > >
> > > Ben.
> > >
> > > On Tue, Mar 07, 2017 at 09:07:55AM +, Sairam Venugopal wrote:
> > > > Shouldn’t we cast the DWORD to unsigned int for the
> > > GetCurrentProcessId?
> > > >
> > > >
> > > >
> > > >
> > > > On 2/5/17, 8:41 PM, "ovs-dev-boun...@openvswitch.org on behalf of
> > > > Alin
> > > Serdean" <ovs-dev-boun...@openvswitch.org on behalf of
> > > aserd...@cloudbasesolutions.com> wrote:
> > > >
> > > > >getcwd - is used in lib/util.c. getcwd is deprecated on Windows
> > > > >but has _getcwd which is defined in :
> > > > >https://urldefense.proofpoint.com/v2/url?u=https-
> > > 3A__msdn.microsoft.c
> > > > >om_en-2Dus_library_sf98bd4y-28v-3Dvs.120-
> > > 29.aspx=DwICAg=uilaK90D4
> > > >
> > >
> >TOVoH58JNXRgQ=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo
> > > =og4savU
> > > > >MMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk=CVjSRN456APj3-
> > > mMAQuXYxdJ4oUgdu
> > > > >wqZHzkod6cLvQ=
> > > > >
> > > > >getpid - is used in several files (i.e. lib/vlog.c). getpid is
> > > > >also and deprecated and _getpid should be used:
> > > > >https://urldefense.proofpoint.com/v2/url?u=https-
> > > 3A__msdn.microsoft.c
> > > > >om_en-2Dus_library_t2y34y40-28v-3Dvs.120-
> > > 29.aspx=DwICAg=uilaK90D4
> > > >
> > >
> >TOVoH58JNXRgQ=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo
> > > =og4savU
> > > >
> > >
> >MMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk=pDh2W8ECiQdxZdHgHBdW
> > > HIDhLPcTJ9
> > > > >A6rb2n1YcRZ94= The problem using _getpid is that the definition
> > > > >is in .
> > > > >A file called process.h also exists in the lib folder. This will
> > > > >mess up includes.
> > > > >An option would be to use a wrapper like we use for
> > > > >lib/string.h(.in) but that would mean to also add it to the automake
> chain.
> > > > >A simple solution would be to map it to GetCurrentProcessId
> > > > >https://urldefense.proofpoint.com/v2/url?u=https-
> > > 3A__msdn.microsoft.c
> > > > >om_en-2Dus_library_windows_desktop_ms683180-28v-3Dvs.85-
> > > 29.aspx=DwI
> >
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 02/10] windows: add definition of getpid and getcwd

2017-04-18 Thread Ben Pfaff
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().

On Wed, Apr 19, 2017 at 03:31:13AM +, Alin Serdean wrote:
> To bring more to the table:
> From includes
> typedef unsigned long   DWORD;
> Our pid_t is defined:
> https://github.com/openvswitch/ovs/blob/master/include/windows/windefs.h#L41
> 
> I'm wondering if it would be best not to cut corners on this one and just 
> stick to _getpid and do the same thing as we already have for `string.h`.
> 
> What do you think?
> 
> Thanks,
> Alin.
> > -Original Message-
> > From: Ben Pfaff [mailto:b...@ovn.org]
> > Sent: Saturday, April 15, 2017 6:27 AM
> > To: Sairam Venugopal <vsai...@vmware.com>
> > Cc: Alin Serdean <aserd...@cloudbasesolutions.com>;
> > d...@openvswitch.org
> > Subject: Re: [ovs-dev] [PATCH 02/10] windows: add definition of getpid and
> > getcwd
> > 
> > If GetCurrentProcessId() is a reasonable substitute for getpid(), but the
> > return type is different, then I would suggest an inline function, like 
> > this:
> > 
> > static inline pid_t
> > getpid(void)
> > {
> > return GetCurrentProcessId();
> > }
> > 
> > Thanks,
> > 
> > Ben.
> > 
> > On Tue, Mar 07, 2017 at 09:07:55AM +, Sairam Venugopal wrote:
> > > Shouldn’t we cast the DWORD to unsigned int for the
> > GetCurrentProcessId?
> > >
> > >
> > >
> > >
> > > On 2/5/17, 8:41 PM, "ovs-dev-boun...@openvswitch.org on behalf of Alin
> > Serdean" <ovs-dev-boun...@openvswitch.org on behalf of
> > aserd...@cloudbasesolutions.com> wrote:
> > >
> > > >getcwd - is used in lib/util.c. getcwd is deprecated on Windows but
> > > >has _getcwd which is defined in :
> > > >https://urldefense.proofpoint.com/v2/url?u=https-
> > 3A__msdn.microsoft.c
> > > >om_en-2Dus_library_sf98bd4y-28v-3Dvs.120-
> > 29.aspx=DwICAg=uilaK90D4
> > >
> > >TOVoH58JNXRgQ=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo
> > =og4savU
> > > >MMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk=CVjSRN456APj3-
> > mMAQuXYxdJ4oUgdu
> > > >wqZHzkod6cLvQ=
> > > >
> > > >getpid - is used in several files (i.e. lib/vlog.c). getpid is also
> > > >and deprecated and _getpid should be used:
> > > >https://urldefense.proofpoint.com/v2/url?u=https-
> > 3A__msdn.microsoft.c
> > > >om_en-2Dus_library_t2y34y40-28v-3Dvs.120-
> > 29.aspx=DwICAg=uilaK90D4
> > >
> > >TOVoH58JNXRgQ=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo
> > =og4savU
> > >
> > >MMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk=pDh2W8ECiQdxZdHgHBdW
> > HIDhLPcTJ9
> > > >A6rb2n1YcRZ94= The problem using _getpid is that the definition is
> > > >in .
> > > >A file called process.h also exists in the lib folder. This will mess
> > > >up includes.
> > > >An option would be to use a wrapper like we use for lib/string.h(.in)
> > > >but that would mean to also add it to the automake chain.
> > > >A simple solution would be to map it to GetCurrentProcessId
> > > >https://urldefense.proofpoint.com/v2/url?u=https-
> > 3A__msdn.microsoft.c
> > > >om_en-2Dus_library_windows_desktop_ms683180-28v-3Dvs.85-
> > 29.aspx=DwI
> 
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 02/10] windows: add definition of getpid and getcwd

2017-04-18 Thread Alin Serdean
To bring more to the table:
From includes
typedef unsigned long   DWORD;
Our pid_t is defined:
https://github.com/openvswitch/ovs/blob/master/include/windows/windefs.h#L41

I'm wondering if it would be best not to cut corners on this one and just stick 
to _getpid and do the same thing as we already have for `string.h`.

What do you think?

Thanks,
Alin.
> -Original Message-
> From: Ben Pfaff [mailto:b...@ovn.org]
> Sent: Saturday, April 15, 2017 6:27 AM
> To: Sairam Venugopal <vsai...@vmware.com>
> Cc: Alin Serdean <aserd...@cloudbasesolutions.com>;
> d...@openvswitch.org
> Subject: Re: [ovs-dev] [PATCH 02/10] windows: add definition of getpid and
> getcwd
> 
> If GetCurrentProcessId() is a reasonable substitute for getpid(), but the
> return type is different, then I would suggest an inline function, like this:
> 
> static inline pid_t
> getpid(void)
> {
> return GetCurrentProcessId();
> }
> 
> Thanks,
> 
> Ben.
> 
> On Tue, Mar 07, 2017 at 09:07:55AM +, Sairam Venugopal wrote:
> > Shouldn’t we cast the DWORD to unsigned int for the
> GetCurrentProcessId?
> >
> >
> >
> >
> > On 2/5/17, 8:41 PM, "ovs-dev-boun...@openvswitch.org on behalf of Alin
> Serdean" <ovs-dev-boun...@openvswitch.org on behalf of
> aserd...@cloudbasesolutions.com> wrote:
> >
> > >getcwd - is used in lib/util.c. getcwd is deprecated on Windows but
> > >has _getcwd which is defined in :
> > >https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__msdn.microsoft.c
> > >om_en-2Dus_library_sf98bd4y-28v-3Dvs.120-
> 29.aspx=DwICAg=uilaK90D4
> >
> >TOVoH58JNXRgQ=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo
> =og4savU
> > >MMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk=CVjSRN456APj3-
> mMAQuXYxdJ4oUgdu
> > >wqZHzkod6cLvQ=
> > >
> > >getpid - is used in several files (i.e. lib/vlog.c). getpid is also
> > >and deprecated and _getpid should be used:
> > >https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__msdn.microsoft.c
> > >om_en-2Dus_library_t2y34y40-28v-3Dvs.120-
> 29.aspx=DwICAg=uilaK90D4
> >
> >TOVoH58JNXRgQ=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo
> =og4savU
> >
> >MMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk=pDh2W8ECiQdxZdHgHBdW
> HIDhLPcTJ9
> > >A6rb2n1YcRZ94= The problem using _getpid is that the definition is
> > >in .
> > >A file called process.h also exists in the lib folder. This will mess
> > >up includes.
> > >An option would be to use a wrapper like we use for lib/string.h(.in)
> > >but that would mean to also add it to the automake chain.
> > >A simple solution would be to map it to GetCurrentProcessId
> > >https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__msdn.microsoft.c
> > >om_en-2Dus_library_windows_desktop_ms683180-28v-3Dvs.85-
> 29.aspx=DwI

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 02/10] windows: add definition of getpid and getcwd

2017-04-14 Thread Ben Pfaff
If GetCurrentProcessId() is a reasonable substitute for getpid(), but
the return type is different, then I would suggest an inline function,
like this:

static inline pid_t
getpid(void)
{
return GetCurrentProcessId();
}

Thanks,

Ben.

On Tue, Mar 07, 2017 at 09:07:55AM +, Sairam Venugopal wrote:
> Shouldn’t we cast the DWORD to unsigned int for the GetCurrentProcessId?
> 
> 
> 
> 
> On 2/5/17, 8:41 PM, "ovs-dev-boun...@openvswitch.org on behalf of Alin 
> Serdean"  aserd...@cloudbasesolutions.com> wrote:
> 
> >getcwd - is used in lib/util.c. getcwd is deprecated on Windows but has
> >_getcwd which is defined in :
> >https://urldefense.proofpoint.com/v2/url?u=https-3A__msdn.microsoft.com_en-2Dus_library_sf98bd4y-28v-3Dvs.120-29.aspx=DwICAg=uilaK90D4TOVoH58JNXRgQ=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo=og4savUMMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk=CVjSRN456APj3-mMAQuXYxdJ4oUgduwqZHzkod6cLvQ=
> > 
> >
> >getpid - is used in several files (i.e. lib/vlog.c). getpid
> >is also and deprecated and _getpid should be used:
> >https://urldefense.proofpoint.com/v2/url?u=https-3A__msdn.microsoft.com_en-2Dus_library_t2y34y40-28v-3Dvs.120-29.aspx=DwICAg=uilaK90D4TOVoH58JNXRgQ=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo=og4savUMMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk=pDh2W8ECiQdxZdHgHBdWHIDhLPcTJ9A6rb2n1YcRZ94=
> > 
> >The problem using _getpid is that the definition is in .
> >A file called process.h also exists in the lib folder. This will mess up
> >includes.
> >An option would be to use a wrapper like we use for lib/string.h(.in) but
> >that would mean to also add it to the automake chain.
> >A simple solution would be to map it to GetCurrentProcessId
> >https://urldefense.proofpoint.com/v2/url?u=https-3A__msdn.microsoft.com_en-2Dus_library_windows_desktop_ms683180-28v-3Dvs.85-29.aspx=DwICAg=uilaK90D4TOVoH58JNXRgQ=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo=og4savUMMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk=QWV0dTQAbL1Jt9ZeQeUAUs-WBb8w5YW0mn1cHxFeaZs=
> > 
> >The disadvantage is the type but Windows recycles pids so in theory
> >it should be ok.
> >
> >Signed-off-by: Alin Gabriel Serdean 
> >---
> > include/windows/unistd.h | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> >diff --git a/include/windows/unistd.h b/include/windows/unistd.h
> >index 8629f7e..3f92616 100644
> >--- a/include/windows/unistd.h
> >+++ b/include/windows/unistd.h
> >@@ -18,8 +18,11 @@
> > 
> > #define WIN32_LEAN_AND_MEAN
> > #include 
> >+#include 
> > 
> > #define fsync _commit
> >+#define getpid GetCurrentProcessId
> >+#define getcwd _getcwd
> > 
> > /* Standard file descriptors.  */
> > #define STDIN_FILENO0   /* Standard input.  */
> >-- 
> >2.10.2.windows.1
> >___
> >dev mailing list
> >d...@openvswitch.org
> >https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.openvswitch.org_mailman_listinfo_ovs-2Ddev=DwICAg=uilaK90D4TOVoH58JNXRgQ=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo=og4savUMMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk=864IlShezC_8X9CmDoHDkTjOqBJ3IcRu1LeeoRJrhdM=
> > 
> ___
> dev mailing list
> d...@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 02/10] windows: add definition of getpid and getcwd

2017-03-07 Thread Sairam Venugopal
Shouldn’t we cast the DWORD to unsigned int for the GetCurrentProcessId?




On 2/5/17, 8:41 PM, "ovs-dev-boun...@openvswitch.org on behalf of Alin Serdean" 
 
wrote:

>getcwd - is used in lib/util.c. getcwd is deprecated on Windows but has
>_getcwd which is defined in :
>https://urldefense.proofpoint.com/v2/url?u=https-3A__msdn.microsoft.com_en-2Dus_library_sf98bd4y-28v-3Dvs.120-29.aspx=DwICAg=uilaK90D4TOVoH58JNXRgQ=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo=og4savUMMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk=CVjSRN456APj3-mMAQuXYxdJ4oUgduwqZHzkod6cLvQ=
> 
>
>getpid - is used in several files (i.e. lib/vlog.c). getpid
>is also and deprecated and _getpid should be used:
>https://urldefense.proofpoint.com/v2/url?u=https-3A__msdn.microsoft.com_en-2Dus_library_t2y34y40-28v-3Dvs.120-29.aspx=DwICAg=uilaK90D4TOVoH58JNXRgQ=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo=og4savUMMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk=pDh2W8ECiQdxZdHgHBdWHIDhLPcTJ9A6rb2n1YcRZ94=
> 
>The problem using _getpid is that the definition is in .
>A file called process.h also exists in the lib folder. This will mess up
>includes.
>An option would be to use a wrapper like we use for lib/string.h(.in) but
>that would mean to also add it to the automake chain.
>A simple solution would be to map it to GetCurrentProcessId
>https://urldefense.proofpoint.com/v2/url?u=https-3A__msdn.microsoft.com_en-2Dus_library_windows_desktop_ms683180-28v-3Dvs.85-29.aspx=DwICAg=uilaK90D4TOVoH58JNXRgQ=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo=og4savUMMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk=QWV0dTQAbL1Jt9ZeQeUAUs-WBb8w5YW0mn1cHxFeaZs=
> 
>The disadvantage is the type but Windows recycles pids so in theory
>it should be ok.
>
>Signed-off-by: Alin Gabriel Serdean 
>---
> include/windows/unistd.h | 3 +++
> 1 file changed, 3 insertions(+)
>
>diff --git a/include/windows/unistd.h b/include/windows/unistd.h
>index 8629f7e..3f92616 100644
>--- a/include/windows/unistd.h
>+++ b/include/windows/unistd.h
>@@ -18,8 +18,11 @@
> 
> #define WIN32_LEAN_AND_MEAN
> #include 
>+#include 
> 
> #define fsync _commit
>+#define getpid GetCurrentProcessId
>+#define getcwd _getcwd
> 
> /* Standard file descriptors.  */
> #define STDIN_FILENO0   /* Standard input.  */
>-- 
>2.10.2.windows.1
>___
>dev mailing list
>d...@openvswitch.org
>https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.openvswitch.org_mailman_listinfo_ovs-2Ddev=DwICAg=uilaK90D4TOVoH58JNXRgQ=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo=og4savUMMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk=864IlShezC_8X9CmDoHDkTjOqBJ3IcRu1LeeoRJrhdM=
> 
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 02/10] windows: add definition of getpid and getcwd

2017-02-05 Thread Alin Serdean
getcwd - is used in lib/util.c. getcwd is deprecated on Windows but has
_getcwd which is defined in :
https://msdn.microsoft.com/en-us/library/sf98bd4y(v=vs.120).aspx

getpid - is used in several files (i.e. lib/vlog.c). getpid
is also and deprecated and _getpid should be used:
https://msdn.microsoft.com/en-us/library/t2y34y40(v=vs.120).aspx
The problem using _getpid is that the definition is in .
A file called process.h also exists in the lib folder. This will mess up
includes.
An option would be to use a wrapper like we use for lib/string.h(.in) but
that would mean to also add it to the automake chain.
A simple solution would be to map it to GetCurrentProcessId
https://msdn.microsoft.com/en-us/library/windows/desktop/ms683180(v=vs.85).aspx
The disadvantage is the type but Windows recycles pids so in theory
it should be ok.

Signed-off-by: Alin Gabriel Serdean 
---
 include/windows/unistd.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/windows/unistd.h b/include/windows/unistd.h
index 8629f7e..3f92616 100644
--- a/include/windows/unistd.h
+++ b/include/windows/unistd.h
@@ -18,8 +18,11 @@
 
 #define WIN32_LEAN_AND_MEAN
 #include 
+#include 
 
 #define fsync _commit
+#define getpid GetCurrentProcessId
+#define getcwd _getcwd
 
 /* Standard file descriptors.  */
 #define STDIN_FILENO0   /* Standard input.  */
-- 
2.10.2.windows.1
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev