This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
[PATCH] add get_nprocs, get_nprocs_conf
- From: "Yaakov (Cygwin/X)" <yselkowitz at users dot sourceforge dot net>
- To: cygwin-patches at cygwin dot com
- Date: Wed, 11 Nov 2009 01:23:33 -0600
- Subject: [PATCH] add get_nprocs, get_nprocs_conf
get_nprocs and get_nprocs_conf are GNU extensions which do the same
thing as sysconf(_SC_NPROCESSORS_CONF/_ONLN).[1]
Patch attached.
Yaakov
[1] http://www.gnu.org/s/libc/manual/html_node/Processor-Resources.html
2009-11-11 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.
* include/cygwin/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 11 Nov 2009 07:07:51 -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 11 Nov 2009 07:07:52 -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 11 Nov 2009 07:07:52 -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/sysinfo.h
===================================================================
RCS file: include/cygwin/sysinfo.h
diff -N include/cygwin/sysinfo.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ include/cygwin/sysinfo.h 11 Nov 2009 07:07:53 -0000
@@ -0,0 +1,17 @@
+/* cygwin/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. */
+
+#ifndef _CYGWIN_SYSINFO_H
+#define _CYGWIN_SYSINFO_H
+
+int get_nprocs_conf (void);
+int get_nprocs (void);
+
+#endif /* _CYGWIN_SYSINFO_H */
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 11 Nov 2009 07:07:53 -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 11 Nov 2009 07:07:53 -0000
@@ -0,0 +1,18 @@
+/* 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
+
+#include <cygwin/sysinfo.h>
+
+#endif /* _SYS_SYSINFO_H */