sysconf.c patch

Nikola Vladov <[email protected]>
Newsgroups gmane.linux.lib.dietlibc
Message-ID <[email protected]>
I don't know if sysinfo() is available on all ARCHs.  Of any case
ngetty uses sysinfo and builds on archlinux, debian, ubuntu using it.


--- sysconf_orig.c	Wed May 20 11:29:17 2009
+++ sysconf.c	Wed May 20 11:20:42 2009
@@ -6,6 +6,17 @@
 
 extern int __sc_nr_cpus();
 
+#if 1
+#include <sys/sysinfo.h>
+
+static long physpages() {
+  struct sysinfo si;
+  if (sysinfo(&si)) return -1;
+  /* si.totalram is unsigned long; why return is long? */
+  return si.totalram;
+}
+
+#else
 static long physpages() {
   int fd=open("/proc/meminfo",O_RDONLY);
   char buf[2048];
@@ -28,6 +39,7 @@
   close(fd);
   return l*1024;
 }
+#endif
 
 long sysconf(int name)
 {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.