Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/smmap/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/smmap/__pycache__/util.cpython-311.pyc

�

�܋f>���dZddlZddlZddlmZmZddlmZgd�Zd�Zd�ZGd�d	��Z	Gd
�d��Z
Gd�d
e��ZdS)zlModule containing a memory memory manager which provides a sliding window on a number of memory mapped files�N)�mmap�ACCESS_READ��ALLOCATIONGRANULARITY)�
align_to_mmap�	is_64_bit�	MapWindow�	MapRegion�
MapRegionListrc�N�|tztz}|r||kr
|tz
}|S)a=
    Align the given integer number to the closest page offset, which usually is 4096 bytes.

    :param round_up: if True, the next higher multiple of page size is used, otherwise
        the lower page_size will be used (i.e. if True, 1 becomes 4096, otherwise it becomes 0)
    :return: num rounded to closest pager)�num�round_up�ress   �[/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/smmap/util.pyrrs5���'�'�+@�
@�C��%�S�C�Z�Z��$�$���J�c�"�tjdkS)zO:return: True if the system is 64 bit. Otherwise it can be assumed to be 32 bitl��)�sys�maxsize�rrrrs���;��&�&rc�P�eZdZdZdZd�Zd�Zed���Zd�Z	d�Z
d�Zd	�Zd
S)r	zWUtility type which is used to snap windows towards each other, and to adjust their size��ofs�sizec�"�||_||_dS�Nr)�self�offsetrs   r�__init__zMapWindow.__init__-s�������	�	�	rc�$�d|j|jfzS)NzMapWindow(%i, %i)r�rs r�__repr__zMapWindow.__repr__1s��"�d�h��	�%:�:�:rc�H�||j|�����S)z!:return: new window from a region��_br)�cls�regions  r�from_regionzMapWindow.from_region4s ���s�6�9�f�k�k�m�m�,�,�,rc� �|j|jzSrrr s r�ofs_endzMapWindow.ofs_end9s���x�$�)�#�#rc��t|jd��}|xj|j|z
z
c_||_t|jd��|_dS)z<Assures the previous window area is contained in the new oner�N)rrr)r�nofss  r�alignzMapWindow.align<sG���T�X�q�)�)���	�	�T�X��_�$�	�	����!�$�)�Q�/�/��	�	�	rc��|j|���z
}||jz}||t||��z
z}|j|z
|_|xj|z
c_dS)z�Adjust the offset to start where the given window on our left ends if possible,
        but don't make yourself larger than max_size.
        The resize will assure that the new window still contains the old window areaN)rr)r�min)r�window�max_size�rofs�nsizes     r�extend_left_tozMapWindow.extend_left_toCs`���x�&�.�.�*�*�*���t�y� �����E�8�,�,�,�,���8�d�?����	�	�T��	�	�	�	rc�t�t|j|j|���z
z|��|_dS)zpAdjust the size to make our window end where the right window begins, but don't
        get larger than max_sizeN)r/rrr))rr0r1s   r�extend_right_tozMapWindow.extend_right_toMs/����	�V�Z�$�,�,�.�.�%@�A�8�L�L��	�	�	rN)
�__name__�
__module__�__qualname__�__doc__�	__slots__rr!�classmethodr'r)r-r4r6rrrr	r	%s�������a�a��I�
���;�;�;��-�-��[�-�$�$�$�0�0�0����M�M�M�M�Mrr	c�`�eZdZdZgd�Zdd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
dd�Zd�ZdS)r
z{Defines a mapped region of memory, aligned to pagesizes

    **Note:** deallocates used region automatically on destruction)r$�_mf�_uc�_size�__weakref__rc	��||_d|_d|_t|t��r|}n9tj|t
jtt
dd��z|z��}	tt|���}|}|}ttj|��j
|z
|��}	t||	fi|��|_t!|j��|_t|t"��rtj|��n/#t|t"��rtj|��wwxYw|���dS)a�Initialize a region, allocate the memory map
        :param path_or_fd: path to the file to map, or the opened file descriptor
        :param ofs: **aligned** offset into the file to be mapped
        :param size: if size is larger then the file on disk, the whole file will be
            allocated the the size automatically adjusted
        :param flags: additional flags to be given when opening the file.
        :raise Exception: if no memory can be allocatedr�O_BINARY)�accessrN)r$r@r?�
isinstance�int�os�open�O_RDONLY�getattr�dictrr/�fstat�st_sizerr>�len�str�close�increment_client_count)
r�
path_or_fdrr�flags�fd�kwargs�corrected_size�sizeofs�actual_sizes
          rrzMapRegion.__init__cs/�������
�����j�#�&�&�	W��B�B����R�[�7�2�z�1�3M�3M�%M�PU�%U�V�V�B�	���S�9�9�9�F�!�N��G�
�b�h�r�l�l�2�W�<�n�M�M�K��B��6�6�v�6�6�D�H��T�X���D�J��*�c�*�*�
����������*�c�*�*�
��������
����
	
�#�#�%�%�%�%�%s
�(A0D�,D.c�>�d|j|���fzS)NzMapRegion<%i, %i>r#r s rr!zMapRegion.__repr__�s��"�d�g�t�y�y�{�{�%;�;�;rc��|jS)z':return: a buffer containing the memory�r>r s r�bufferzMapRegion.buffer��	���x�rc��|jS)z+:return: a memory map containing the memoryr[r s r�mapz
MapRegion.map�r]rc��|jS)z>:return: absolute byte offset to the first byte of the mapping)r$r s r�	ofs_beginzMapRegion.ofs_begin�s	���w�rc��|jS)z1:return: total size of the mapped region in bytes)r@r s rrzMapRegion.size�s
���z�rc� �|j|jzS)zE:return: Absolute offset to one byte beyond the mapping into the file�r$r@r s rr)zMapRegion.ofs_end�s���w���#�#rc�F�|j|cxko|j|jzkncS)zB:return: True if the given offset can be read in our mapped regionrd�rrs  r�includes_ofszMapRegion.includes_ofs�s/���w�#�4�4�4�4���$�*� 4�4�4�4�4�4rc��|jS)z6:return: number of clients currently using this region)r?r s r�client_countzMapRegion.client_count�r]rr+c��|xj|z
c_|jdksJd|jz���|���dkr|���dSdS)z�Adjust the usage count by the given positive or negative offset.
        If usage count equals 0, we will auto-release our resources
        :return: True if we released resources, False otherwise. In the latter case, we can still be used���z<Increments must match decrements, usage counter negative: %irTF)r?ri�releaserfs  rrQz MapRegion.increment_client_count�s`��	
���C�����x�"�}�}�}�\�_c�_g�g�}�}�}������!�#�#��L�L�N�N�N��4��5rc�8�|j���dS)zbRelease all resources this instance might hold. Must only be called if there usage_count() is zeroN)r>rPr s rrlzMapRegion.release�s����������rN)r)r+)r7r8r9r:r;rr!r\r_rarr)rgrirQrlrrrr
r
Ss�������F�F����I�%&�%&�%&�%&�N<�<�<�
������������$�$�$�5�5�5������������rr
c�8��eZdZdZdZ�fd�Zd�Zd�Zd�Z�xZ	S)rzFList of MapRegion instances associating a path with a list of regions.��_path_or_fd�
_file_sizec�F��t���|��Sr)�super�__new__)r%�path�	__class__s  �rrtzMapRegionList.__new__�s����w�w���s�#�#�#rc�"�||_d|_dSrro)rrRs  rrzMapRegionList.__init__�s��%�������rc��|jS)z3:return: path or file descriptor we are attached to)rpr s rrRzMapRegionList.path_or_fd�s����rc���|j�at|jt��r$t	j|j��j|_n#t	j|j��j|_|jS)z :return: size of file we manager)rqrErprOrG�statrMrLr s r�	file_sizezMapRegionList.file_size�sZ���?�"��$�*�C�0�0�
E�"$�'�$�*:�";�";�"C����"$�(�4�+;�"<�"<�"D�����r)
r7r8r9r:r;rtrrRr{�
__classcell__)rvs@rrr�sr�������P�P��I�
$�$�$�$�$���� � � �	�	�	�	�	�	�	rr)
r:rGrrrr�__all__rrr	r
�listrrrr�<module>rs��r�r�	�	�	�	�
�
�
�
�"�"�"�"�"�"�"�"�&�&�&�&�&�&�O�O�O�����'�'�'�+M�+M�+M�+M�+M�+M�+M�+M�\h�h�h�h�h�h�h�h�Z�����D�����r

Hacked By AnonymousFox1.0, Coded By AnonymousFox