This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: [PATCH] add get_nprocs, get_nprocs_conf
On 12/11/2009 03:44, Corinna Vinschen wrote:
In this case I'm rather surprised that these very GNU/Linux specific
things are *not* in a linux/sysinfo.h file. But it doesn't hurt to keep
that in line with Linux, right?
In that case, here is a patch which declares directly in sys/sysinfo.h.
Yaakov
2009-11-12 Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
* sysconf.cc (get_nprocs, get_nprocs_conf): New functions.
* cygwin.din: Export them.
* include/sys/sysinfo.h: New header.
(get_nprocs, get_nprocs_conf): Declare.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
* posix.sgml: Mention them as GNU extensions.
Index: cygwin.din
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/cygwin.din,v
retrieving revision 1.216
diff -u -r1.216 cygwin.din
--- cygwin.din 26 Sep 2009 21:01:10 -0000 1.216
+++ cygwin.din 12 Nov 2009 10:06:45 -0000
@@ -598,6 +598,8 @@
_gcvt = gcvt SIGFE
gcvtf SIGFE
_gcvtf = gcvtf SIGFE
+get_nprocs SIGFE
+get_nprocs_conf SIGFE
get_osfhandle SIGFE
_get_osfhandle = get_osfhandle SIGFE
getaddrinfo = cygwin_getaddrinfo SIGFE
Index: posix.sgml
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/posix.sgml,v
retrieving revision 1.39
diff -u -r1.39 posix.sgml
--- posix.sgml 26 Sep 2009 21:01:10 -0000 1.39
+++ posix.sgml 12 Nov 2009 10:06:47 -0000
@@ -1026,6 +1026,8 @@
fopencookie
fremovexattr
fsetxattr
+ get_nprocs
+ get_nprocs_conf
getopt_long
getopt_long_only
getxattr
Index: sysconf.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/sysconf.cc,v
retrieving revision 1.52
diff -u -r1.52 sysconf.cc
--- sysconf.cc 7 Apr 2008 18:45:59 -0000 1.52
+++ sysconf.cc 12 Nov 2009 10:06:48 -0000
@@ -292,3 +292,15 @@
set_errno (EINVAL);
return 0;
}
+
+extern "C" int
+get_nprocs_conf (void)
+{
+ return get_nproc_values(_SC_NPROCESSORS_CONF);
+}
+
+extern "C" int
+get_nprocs (void)
+{
+ return get_nproc_values(_SC_NPROCESSORS_ONLN);
+}
Index: include/cygwin/version.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/version.h,v
retrieving revision 1.302
diff -u -r1.302 version.h
--- include/cygwin/version.h 31 Oct 2009 13:24:06 -0000 1.302
+++ include/cygwin/version.h 12 Nov 2009 10:06:48 -0000
@@ -371,12 +371,13 @@
215: CW_EXIT_PROCESS added.
216: CW_SET_EXTERNAL_TOKEN added.
217: CW_GET_INSTKEY added.
+ 218: Export get_nprocs, get_nprocs_conf.
*/
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 217
+#define CYGWIN_VERSION_API_MINOR 218
/* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible
Index: include/sys/sysinfo.h
===================================================================
RCS file: include/sys/sysinfo.h
diff -N include/sys/sysinfo.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ include/sys/sysinfo.h 12 Nov 2009 10:06:48 -0000
@@ -0,0 +1,19 @@
+/* sys/sysinfo.h
+
+ Copyright 2009 Red Hat, Inc.
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+/* sys/sysinfo.h header file for Cygwin. */
+
+#ifndef _SYS_SYSINFO_H
+#define _SYS_SYSINFO_H
+
+int get_nprocs_conf (void);
+int get_nprocs (void);
+
+#endif /* _SYS_SYSINFO_H */