mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-29 18:52:30 +00:00 
			
		
		
		
	Ensure static IdStrings get prepopulated when initializing yosys
An alternative would be to call ensure_prepopulated() in various IdString methods.
This commit is contained in:
		
							parent
							
								
									b6db32873d
								
							
						
					
					
						commit
						a97381448a
					
				
					 2 changed files with 9 additions and 2 deletions
				
			
		|  | @ -217,8 +217,7 @@ struct RTLIL::IdString | ||||||
| 			return it->second; | 			return it->second; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if (global_id_index_.empty()) | 		ensure_prepopulated(); | ||||||
| 			prepopulate(); |  | ||||||
| 
 | 
 | ||||||
| 		if (!p[0]) | 		if (!p[0]) | ||||||
| 			return 0; | 			return 0; | ||||||
|  | @ -457,6 +456,12 @@ struct RTLIL::IdString | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
| 	static void prepopulate(); | 	static void prepopulate(); | ||||||
|  | 
 | ||||||
|  | public: | ||||||
|  | 	static void ensure_prepopulated() { | ||||||
|  | 		if (global_id_index_.empty()) | ||||||
|  | 			prepopulate(); | ||||||
|  | 	} | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| namespace hashlib { | namespace hashlib { | ||||||
|  |  | ||||||
|  | @ -196,6 +196,8 @@ void yosys_setup() | ||||||
| 	already_setup = true; | 	already_setup = true; | ||||||
| 	already_shutdown = false; | 	already_shutdown = false; | ||||||
| 
 | 
 | ||||||
|  | 	IdString::ensure_prepopulated(); | ||||||
|  | 
 | ||||||
| #ifdef WITH_PYTHON | #ifdef WITH_PYTHON | ||||||
| 	// With Python 3.12, calling PyImport_AppendInittab on an already
 | 	// With Python 3.12, calling PyImport_AppendInittab on an already
 | ||||||
| 	// initialized platform fails (such as when libyosys is imported
 | 	// initialized platform fails (such as when libyosys is imported
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue