| 
									
										
										
										
											2010-03-29 02:23:21 -04:00
										 |  |  | #include "master.hpp"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:14:17 -04:00
										 |  |  | namespace factor { | 
					
						
							| 
									
										
										
										
											2010-03-29 02:23:21 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-29 02:27:45 -04:00
										 |  |  | pthread_key_t current_vm_tls_key; | 
					
						
							| 
									
										
										
										
											2010-03-29 02:23:21 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:14:17 -04:00
										 |  |  | void init_mvm() { | 
					
						
							|  |  |  |   if (pthread_key_create(¤t_vm_tls_key, NULL) != 0) | 
					
						
							|  |  |  |     fatal_error("pthread_key_create() failed", 0); | 
					
						
							| 
									
										
										
										
											2010-03-29 02:23:21 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:14:17 -04:00
										 |  |  | void register_vm_with_thread(factor_vm* vm) { | 
					
						
							|  |  |  |   pthread_setspecific(current_vm_tls_key, vm); | 
					
						
							| 
									
										
										
										
											2010-03-29 02:23:21 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:14:17 -04:00
										 |  |  | factor_vm* current_vm_p() { | 
					
						
							|  |  |  |   return (factor_vm*)pthread_getspecific(current_vm_tls_key); | 
					
						
							| 
									
										
										
										
											2010-03-29 02:23:21 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |