File: //opt/saltstack/salt/lib/python3.10/site-packages/smmap/__pycache__/util.cpython-310.pyc
o
;j4 � @ sx d Z ddlZddlZddlmZmZ ddlmZ g d�Zdd� Zdd � ZG d
d� d�Z G dd
� d
�Z
G dd� de�ZdS )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�
MapRegionListr c C s$ | t t }|r|| kr|t 7 }|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 )�numZround_up�res� r
�>/opt/saltstack/salt/lib/python3.10/site-packages/smmap/util.pyr s r c C s
t jdkS )zO:return: True if the system is 64 bit. Otherwise it can be assumed to be 32 bitl �� )�sys�maxsizer
r
r
r r s
r c @ sP e Zd ZdZdZdd� Zdd� Zedd� �Zd d
� Z dd� Z
d
d� Zdd� ZdS )r zWUtility type which is used to snap windows towards each other, and to adjust their size��ofs�sizec C s || _ || _d S �Nr )�self�offsetr r
r
r �__init__- �
zMapWindow.__init__c C s d| j | jf S )NzMapWindow(%i, %i)r �r r
r
r �__repr__1 s zMapWindow.__repr__c C s | |j |�� �S )z!:return: new window from a region��_br )�clsZregionr
r
r �from_region4 s zMapWindow.from_regionc C � | j | j S r r r r
r
r �ofs_end9 � zMapWindow.ofs_endc C s8 t | jd�}| j| j| 7 _|| _t | jd�| _dS )z<Assures the previous window area is contained in the new oner � N)r r r )r Znofsr
r
r �align<