| 
									
										
										
										
											2013-03-17 13:30:12 -05:00
										 |  |  | module LinuxCPUs | 
					
						
							| 
									
										
										
										
											2013-06-13 11:57:13 -05:00
										 |  |  |   OPTIMIZATION_FLAGS = {}.freeze | 
					
						
							|  |  |  |   def optimization_flags; OPTIMIZATION_FLAGS; end | 
					
						
							| 
									
										
										
										
											2013-03-17 13:30:12 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-14 20:05:54 -07:00
										 |  |  |   # Linux supports x86 only, and universal archs do not apply | 
					
						
							|  |  |  |   def arch_32_bit; :i386; end | 
					
						
							|  |  |  |   def arch_64_bit; :x86_64; end | 
					
						
							| 
									
										
										
										
											2013-08-29 16:50:11 -07:00
										 |  |  |   def universal_archs; [].extend ArchitectureListExtension; end | 
					
						
							| 
									
										
										
										
											2013-08-14 20:05:54 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-17 13:30:12 -05:00
										 |  |  |   def type | 
					
						
							|  |  |  |     @cpu_type ||= case `uname -m` | 
					
						
							| 
									
										
										
										
											2013-06-29 10:51:11 -07:00
										 |  |  |       when /i[3-6]86/, /x86_64/ | 
					
						
							| 
									
										
										
										
											2013-03-10 17:33:06 +00:00
										 |  |  |         :intel | 
					
						
							|  |  |  |       else | 
					
						
							|  |  |  |         :dunno | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-17 13:30:12 -05:00
										 |  |  |   def family | 
					
						
							| 
									
										
										
										
											2013-03-10 17:33:06 +00:00
										 |  |  |     :dunno | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2013-03-23 20:15:51 +01:00
										 |  |  |   alias_method :intel_family, :family | 
					
						
							| 
									
										
										
										
											2013-03-10 17:33:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-17 13:30:12 -05:00
										 |  |  |   def cores | 
					
						
							| 
									
										
										
										
											2013-03-10 17:33:06 +00:00
										 |  |  |     `grep -c ^processor /proc/cpuinfo`.to_i | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-17 13:30:12 -05:00
										 |  |  |   def bits | 
					
						
							|  |  |  |     is_64_bit? ? 64 : 32
 | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-10 17:33:06 +00:00
										 |  |  |   def is_64_bit? | 
					
						
							| 
									
										
										
										
											2013-03-17 13:30:12 -05:00
										 |  |  |     return @is_64_bit if defined? @is_64_bit | 
					
						
							|  |  |  |     @is_64_bit = /64/ === `uname -m` | 
					
						
							| 
									
										
										
										
											2013-03-10 17:33:06 +00:00
										 |  |  |   end | 
					
						
							|  |  |  | end |