
    xKg                         d Z ddlZddlmZ ddlmZ ddlmZm	Z	 ddl
mZ d Zd Zd Z G d	 d
e      Z G d de      Z e       Zy)zD
Register external C functions necessary for Numba code generation.
    N)ir)utils
intrinsics)
_helperlibc                 \    t        j                  |       st        j                  | |       yy)z1Add missing symbol into LLVM internal symtab
    N)lladdress_of_symbol
add_symbol)symboladdrs     X/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/core/externals.py_add_missing_symbolr      s%     '
fd# (    c                 h    ddl m}m}m} t	        |j
                  |       } |||      j                  S )zr
    Under Windows, look up a symbol inside the C runtime
    and return the raw pointer value as an integer.
    r   )cdllcastc_void_p)ctypesr   r   r   getattrmsvcrtvalue)r   r   r   r   fs        r   _get_msvcrt_symbolr      s-    
 ,+V$A8"""r   c           
         | j                         }|j                  d      }|j                  d      }t        j                  d      }t        j                  d      }t        j
                  |d      }t        j
                  |d      }t        j
                  |d      }t        j                  |||g      }	t        j                  ||	d      }
|
j                  \  }}|
j                         }t        j                  |      }|j                  ||      }|j                  ||      }|j                  |j                  ||      |      }|j                  |j                  ||      |      }|j                  |j                  ||      |j                  ||            }|j                  ||      }|j                  ||      }|j!                  ||j                  |j                  ||      |j                  ||                  }|j!                  ||j#                  ||            }|j                  ||      }|j                  ||      }|j                  ||      }|j!                  ||j                  |j                  ||      |j                  ||                  }|j!                  ||j#                  ||            }|j!                  ||j                  ||            }|j!                  ||j                  |j                  ||      |j                  ||                  }|j!                  ||j                  ||            }|j!                  ||j                  ||            }|j%                  ||      }|j!                  ||j#                  |j%                  ||      |            }|j'                  |       |j)                  |       |j+                          |S )zo
    Compile the multi3() helper function used by LLVM
    for 128-bit multiplication on 32-bit platforms.
    multi3@      l        )name)codegencreate_librarycreate_ir_moduler   IntTypeConstantFunctionTypeFunctionargsappend_basic_block	IRBuildertruncashrmuland_lshraddshlzextretadd_ir_modulefinalize)contextr    libraryir_modi64i128
lower_mask_32_64fn_typefnabbbbuilderalblahbhrltrhrs                          r   compile_multi3rK      s.   
 ooG$$X.G%%h/F
**R.C::c?DS*-J
++c2
C
++dB
CoodT4L1G	VW8	4B77DAq				 Bll2G 
q#	B	q#	B	w||As+S	1B	w||As+S	1B 
W\\"j17<<J3O	PBRA	b*	%BAw{{7<<C#8#*<<J#?A 	BA 
RQ,	-B	a	BRA	b*	%BAw{{7<<C#8#*<<J#?A 	BA 
RQ,	-B	Ra-	.B	RW\\"c%:%,\\"c%:< 
=B 
RR,	-B	RR,	-B 	RAAw{{7<<D#93?@AKKN&!Nr   c                       e Zd ZdZd Zy)
_InstallerFc                 N    | j                   s| j                  |       d| _         yy)z
        Install the functions into LLVM.  This only needs to be done once,
        as the mappings are persistent during the process lifetime.
        TN)
_installed_do_install)selfr5   s     r   installz_Installer.installl   s%    
 W%"DO r   N)__name__
__module____qualname__rO   rR    r   r   rM   rM   h   s    J#r   rM   c                       e Zd ZdZd Zy)_ExternalMathFunctionszd
    Map the math functions from the C runtime library into the LLVM
    execution environment.
    c                    t         j                  dk(  }t        j                  }t        j
                  j                  d      r|rt        d      }t        d|       n?t        j
                  j                  d      r |rt        d|d          t        d|d	          |r;t        |      | _
        | j                  j                  d
      }|sJ t        d|       t        j                  D ]  }t        j                  |||           y )Nr   win32_ftol_ftol2linux__fixunsdfdifptoui__fixunssfdifptouifr   __multi3)r   MACHINE_BITSr   	c_helperssysplatform
startswithr   r   rK   _multi3_libget_pointer_to_functionr   	INTR_MATHr   r
   )rQ   r5   is32bitrd   ftolptrfnames          r   rP   z"_ExternalMathFunctions._do_install|   s    $$*((	<<""7+ &g.D$/\\$$W-'	(0CD	)0DE-g6D""::8DCJ3
C0  ))E
 MM%5!12 *r   N)rS   rT   rU   __doc__rP   rV   r   r   rX   rX   v   s    
3r   rX   )ro   re   llvmliter   llvmlite.bindingbindingr   
numba.corer   r   numbar   r   r   rK   objectrM   rX   c_math_functionsrV   r   r   <module>rw      sP       ( $#FR# #"3Z "3J *+ r   