4|Œ OpdZddlZddlZddlmZmZddlmZgdZdZdZGdd 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 filesN)mmap ACCESS_READALLOCATIONGRANULARITY) align_to_mmap is_64_bit MapWindow MapRegion MapRegionListrcN|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)numround_upress /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/smmap/util.pyrrs5 ' '+@ @C%SCZZ $$ Jc"tjdkS)zO:return: True if the system is 64 bit. Otherwise it can be assumed to be 32 bitl)sysmaxsizerrrrs ; &&rcPeZdZdZdZdZdZedZdZ dZ dZ d Z d S) r zWUtility type which is used to snap windows towards each other, and to adjust their sizeofssizec"||_||_dSNr)selfoffsetrs r__init__zMapWindow.__init__-s rc$d|j|jfzS)NzMapWindow(%i, %i)rrs r__repr__zMapWindow.__repr__1s"dh %:::rcH||j|S)z!:return: new window from a region_br)clsregions r from_regionzMapWindow.from_region4s s69fkkmm,,,rc |j|jzSrrr s rofs_endzMapWindow.ofs_end9sx$)##rct|jd}|xj|j|z z c_||_t|jd|_dS)zlenstrcloseincrement_client_count) r path_or_fdrrflagsfdkwargscorrected_sizesizeofs actual_sizes rrzMapRegion.__init__cs/  j# & & WBBR[72z13M3M%MPU%UVVB S999F!NG bhrll2Wd|j|fzS)NzMapRegion<%i, %i>r#r s rr!zMapRegion.__repr__s"dgtyy{{%;;;rc|jS)z':return: a buffer containing the memoryr>r s rbufferzMapRegion.buffer xrc|jS)z+:return: a memory map containing the memoryr[r s rmapz MapRegion.mapr]rc|jS)z>:return: absolute byte offset to the first byte of the mapping)r$r s r ofs_beginzMapRegion.ofs_begins wrc|jS)z1:return: total size of the mapped region in bytes)r@r s rrzMapRegion.sizes zrc |j|jzS)zE:return: Absolute offset to one byte beyond the mapping into the filer$r@r s rr)zMapRegion.ofs_endsw##rcF|j|cxko|j|jzkncS)zB:return: True if the given offset can be read in our mapped regionrdrrs r includes_ofszMapRegion.includes_ofss/w#4444$* 444444rc|jS)z6:return: number of clients currently using this region)r?r s r client_countzMapRegion.client_countr]rr+c|xj|z c_|jdksJd|jz|dkr|dSdS)zAdjust 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 usedzrPr s rrlzMapRegion.releases rN)r)r+)r7r8r9r:r;rr!r\r_rarr)rgrirQrlrrrr r SsFFI%&%&%&%&N<<< $$$555    rr c8eZdZdZdZfdZdZdZdZxZ S)r zFList of MapRegion instances associating a path with a list of regions. _path_or_fd _file_sizecFt|Sr)super__new__)r%path __class__s rrtzMapRegionList.__new__swws###rc"||_d|_dSrro)rrRs rrzMapRegionList.__init__s%rc|jS)z3:return: path or file descriptor we are attached to)rpr s rrRzMapRegionList.path_or_fds rc|jat|jtr$t j|jj|_n#t j|jj|_|jS)z :return: size of file we manager)rqrErprOrGstatrMrLr s r file_sizezMapRegionList.file_sizesZ ? "$*C00 E"$'$*:";";"C"$(4+;"<"<"Dr) r7r8r9r:r;rtrrRr{ __classcell__)rvs@rr r srPPI $$$$$          rr ) r:rGrrrr__all__rrr r listr rrrrsrr """"""""&&&&&& O O O   '''+M+M+M+M+M+M+M+M\hhhhhhhhZDr