Re: [PATCH] add information to /proc/version

2011-04-04 Thread Corinna Vinschen
On Apr  3 18:58, Yaakov (Cygwin/X) wrote:
> On Linux, /proc/version also displays the username of the kernel
> compiler and the version of gcc used to compile[1].  This patch does the
> same for Cygwin:
> [...]
>   * new-features.sgml (ov-new1.7.10): Document additional information
>   in /proc/version.

Funny.  Please apply.


Thanks,
Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  cygwin AT cygwin DOT com
Red Hat


[PATCH] add information to /proc/version

2011-04-03 Thread Yaakov (Cygwin/X)
On Linux, /proc/version also displays the username of the kernel
compiler and the version of gcc used to compile[1].  This patch does the
same for Cygwin:

$ cat /proc/version
CYGWIN_NT-6.1-WOW64 version 1.7.10(0.238/5/3) (Yaakov@YAAKOV04) (gcc
version 4.5.2 (GCC) ) 2011-03-30 18:56

Patches for winsup/cygwin and winsup/doc attached.


Yaakov

[1] 
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s2-proc-version.html

2011-04-03  Yaakov Selkowitz  

	* new-features.sgml (ov-new1.7.10): Document additional information
	in /proc/version.

Index: new-features.sgml
===
RCS file: /cvs/src/src/winsup/doc/new-features.sgml,v
retrieving revision 1.71
diff -u -r1.71 new-features.sgml
--- new-features.sgml	1 Apr 2011 19:49:16 -	1.71
+++ new-features.sgml	3 Apr 2011 23:55:49 -
@@ -20,6 +20,15 @@
 shared memory.
 
 
+
+/proc/version now shows the username of whomever compiled the Cygwin DLL
+as well as the version of GCC used when compiling.
+
+
 
 
 
2011-04-03  Yaakov Selkowitz  

	* Makefile.in (fhandler_proc_CFLAGS): Define USERNAME, HOSTNAME,
	and GCC_VERSION.
	* fhandler_proc.cc (format_proc_version):  Add build machine and GCC
	version information as on Linux.

Index: Makefile.in
===
RCS file: /cvs/src/src/winsup/cygwin/Makefile.in,v
retrieving revision 1.243
diff -u -r1.243 Makefile.in
--- Makefile.in	1 Apr 2011 19:48:19 -	1.243
+++ Makefile.in	3 Apr 2011 23:38:41 -
@@ -287,6 +287,9 @@
 uinfo_CFLAGS:=-fomit-frame-pointer
 endif
 
+fhandler_proc_CFLAGS+=-DUSERNAME="\"$(USER)\"" -DHOSTNAME="\"$(HOSTNAME)\""
+fhandler_proc_CFLAGS+=-DGCC_VERSION="\"`$(CC) -v 2>&1 | tail -n 1`\""
+
 _cygwin_crt0_common_STDINCFLAGS:=yes
 libstdcxx_wrapper_STDINCFLAGS:=yes
 cxx_STDINCFLAGS:=yes
Index: fhandler_proc.cc
===
RCS file: /cvs/src/src/winsup/cygwin/fhandler_proc.cc,v
retrieving revision 1.98
diff -u -r1.98 fhandler_proc.cc
--- fhandler_proc.cc	2 Apr 2011 11:32:55 -	1.98
+++ fhandler_proc.cc	3 Apr 2011 23:38:41 -
@@ -361,15 +361,19 @@
 static _off64_t
 format_proc_version (void *, char *&destbuf)
 {
+  tmp_pathbuf tp;
+  char *buf = tp.c_get ();
+  char *bufptr = buf;
   struct utsname uts_name;
 
   uname (&uts_name);
-  destbuf = (char *) crealloc_abort (destbuf, strlen (uts_name.sysname)
-	  + strlen (uts_name.release)
-	  + strlen (uts_name.version)
-	  + 4);
-  return __small_sprintf (destbuf, "%s %s %s\n",
-			  uts_name.sysname, uts_name.release, uts_name.version);
+  bufptr += __small_sprintf (bufptr, "%s version %s (%s@%s) (%s) %s\n",
+			  uts_name.sysname, uts_name.release, USERNAME, HOSTNAME,
+			  GCC_VERSION, uts_name.version);
+
+  destbuf = (char *) crealloc_abort (destbuf, bufptr - buf);
+  memcpy (destbuf, buf, bufptr - buf);
+  return bufptr - buf;
 }
 
 static _off64_t