| 
									
										
										
										
											2008-12-06 23:58:19 -05:00
										 |  |  | ! Copyright (C) 2008 Doug Coleman. | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2013-04-24 15:05:51 -04:00
										 |  |  | USING: accessors alien.c-types alien.syntax byte-arrays io | 
					
						
							| 
									
										
										
										
											2011-09-09 00:59:03 -04:00
										 |  |  | io.encodings.string io.encodings.utf8 io.streams.byte-array | 
					
						
							| 
									
										
										
										
											2014-04-04 11:03:46 -04:00
										 |  |  | libc kernel sequences splitting strings system system-info unix | 
					
						
							| 
									
										
										
										
											2013-04-24 15:05:51 -04:00
										 |  |  | unix.linux.proc math ;
 | 
					
						
							| 
									
										
										
										
											2008-12-06 23:58:19 -05:00
										 |  |  | IN: system-info.linux | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-14 19:00:11 -04:00
										 |  |  | FUNCTION-ALIAS: (uname) | 
					
						
							| 
									
										
										
										
											2015-07-19 19:54:27 -04:00
										 |  |  |     int uname ( c-string buf )
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : uname ( -- seq )
 | 
					
						
							| 
									
										
										
										
											2011-09-09 00:59:03 -04:00
										 |  |  |     65536 <byte-array> [ (uname) io-error ] keep >string
 | 
					
						
							|  |  |  |     "\0" split harvest dup length 6 assert= ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-09 00:59:03 -04:00
										 |  |  | : sysname ( -- string ) 0 uname nth ;
 | 
					
						
							|  |  |  | : nodename ( -- string ) 1 uname nth ;
 | 
					
						
							|  |  |  | : release ( -- string ) 2 uname nth ;
 | 
					
						
							|  |  |  | : version ( -- string ) 3 uname nth ;
 | 
					
						
							|  |  |  | : machine ( -- string ) 4 uname nth ;
 | 
					
						
							|  |  |  | : domainname ( -- string ) 5 uname nth ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-24 15:05:51 -04:00
										 |  |  | M: linux os-version release ;
 | 
					
						
							|  |  |  | M: linux cpus parse-proc-cpuinfo sort-cpus cpu-counts 2drop ;
 | 
					
						
							|  |  |  | : cores ( -- n ) parse-proc-cpuinfo sort-cpus cpu-counts drop nip ;
 | 
					
						
							|  |  |  | : hyperthreads ( -- n ) parse-proc-cpuinfo sort-cpus cpu-counts 2nip ;
 | 
					
						
							|  |  |  | M: linux cpu-mhz parse-proc-cpuinfo first cpu-mhz>> 1,000,000 * ;
 | 
					
						
							|  |  |  | M: linux physical-mem parse-proc-meminfo mem-total>> ;
 | 
					
						
							| 
									
										
										
										
											2018-07-08 23:46:18 -04:00
										 |  |  | M: linux computer-name nodename ;
 |