| 
									
										
										
										
											2012-06-26 07:58:23 -07:00
										 |  |  | #!/usr/bin/perl -w | 
					
						
							| 
									
										
										
										
											2008-08-27 17:56:44 -07:00
										 |  |  | # | 
					
						
							|  |  |  | # Generate the x86_cap_flags[] array from include/asm-x86/cpufeature.h | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ($in, $out) = @ARGV; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | open(IN, "< $in\0")   or die "$0: cannot open: $in: $!\n"; | 
					
						
							|  |  |  | open(OUT, "> $out\0") or die "$0: cannot create: $out: $!\n"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 18:01:26 +01:00
										 |  |  | print OUT "#ifndef _ASM_X86_CPUFEATURE_H\n"; | 
					
						
							|  |  |  | print OUT "#include <asm/cpufeature.h>\n"; | 
					
						
							|  |  |  | print OUT "#endif\n"; | 
					
						
							|  |  |  | print OUT "\n"; | 
					
						
							| 
									
										
										
										
											2008-08-27 17:56:44 -07:00
										 |  |  | print OUT "const char * const x86_cap_flags[NCAPINTS*32] = {\n"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-22 11:47:15 -07:00
										 |  |  | %features = (); | 
					
						
							|  |  |  | $err = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-27 17:56:44 -07:00
										 |  |  | while (defined($line = <IN>)) { | 
					
						
							|  |  |  | 	if ($line =~ /^\s*\#\s*define\s+(X86_FEATURE_(\S+))\s+(.*)$/) { | 
					
						
							|  |  |  | 		$macro = $1; | 
					
						
							| 
									
										
										
										
											2012-06-22 11:47:15 -07:00
										 |  |  | 		$feature = "\L$2"; | 
					
						
							| 
									
										
										
										
											2008-08-27 17:56:44 -07:00
										 |  |  | 		$tail = $3; | 
					
						
							|  |  |  | 		if ($tail =~ /\/\*\s*\"([^"]*)\".*\*\//) { | 
					
						
							| 
									
										
										
										
											2012-06-22 11:47:15 -07:00
										 |  |  | 			$feature = "\L$1"; | 
					
						
							| 
									
										
										
										
											2008-08-27 17:56:44 -07:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-22 11:47:15 -07:00
										 |  |  | 		next if ($feature eq ''); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if ($features{$feature}++) { | 
					
						
							|  |  |  | 			print STDERR "$in: duplicate feature name: $feature\n"; | 
					
						
							|  |  |  | 			$err++; | 
					
						
							| 
									
										
										
										
											2008-08-27 17:56:44 -07:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-06-26 07:58:23 -07:00
										 |  |  | 		printf OUT "\t%-32s = \"%s\",\n", "[$macro]", $feature; | 
					
						
							| 
									
										
										
										
											2008-08-27 17:56:44 -07:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | print OUT "};\n"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | close(IN); | 
					
						
							|  |  |  | close(OUT); | 
					
						
							| 
									
										
										
										
											2012-06-22 11:47:15 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | if ($err) { | 
					
						
							|  |  |  | 	unlink($out); | 
					
						
							|  |  |  | 	exit(1); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit(0); |