- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 64 位机器上,mmap
与 mmap64
之间有什么区别吗?
还有其他的,例如 fstat64
与 fstat
。
答案:在 64 位 Ubuntu 18 LTS 上,已验证 mmap 和 mmap64 func addr 是否相同。off_t 和 off64_t 是 64 位。
fstat/stat 能够返回 > 2 GiB 文件大小。
代码:
#include <sys/mman.h>
#include <sys/stat.h>
#include <iostream>
using namespace std;
int main(){
cout << sizeof(off_t) << endl;
void* a = (void*)&mmap64;
void * b = (void*)&mmap;
cout << (a ==b) << endl; // same addr
a = (void*)&fstat64;
b = (void*)&fstat;
cout << (a==b) << endl; // diff addr but able to return > 2 GiB size
}
最佳答案
On a 64-bit machine, is there any difference between mmap vs mmap64?
没有。
引入 *64 接口(interface)是为了启用 Large File Support在 32 位系统上。这在 64 位系统上没有区别。
但是,64 位接口(interface)实际上并未直接向用户公开(不是 POSIX 的一部分)。所以你不应该直接使用*64接口(interface)。如果您碰巧在 32 位系统上需要它们,请使用 feature test macros glibc(例如 _FILE_OFFSET_BITS
)。
Macro: _FILE_OFFSET_BITS
This macro determines which file system interface shall be used, one replacing the other. Whereas _LARGEFILE64_SOURCE makes the 64 bit interface available as an additional interface, _FILE_OFFSET_BITS allows the 64 bit interface to replace the old interface.
If _FILE_OFFSET_BITS is undefined, or if it is defined to the value 32, nothing changes. The 32 bit interface is used and types like off_t have a size of 32 bits on 32 bit systems.
If the macro is defined to the value 64, the large file interface replaces the old interface. I.e., the functions are not made available under different names (as they are with _LARGEFILE64_SOURCE). Instead the old function names now reference the new functions, e.g., a call to fseeko now indeed calls fseeko64.
This macro should only be selected if the system provides mechanisms for handling large files. On 64 bit systems this macro has no effect since the *64 functions are identical to the normal functions.
This macro was introduced as part of the Large File Support extension (LFS).
关于c - mmap 与 mmap64 有什么区别吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59453555/
我想了解 mmap 的工作原理。mmap 的用户级调用如下所示。 void *mmap(void *addr, size_t len, int prot, int flags, int
我正在做一个Bottle驱动程序,我使用 yield 关键字和 mmap.mmap 对象在输出流中发送多个映射文件,如以下代码所示: for mapping in mappings: yield
我来自 C++/RAII 世界。 所以我对何时以及如何调用 mmap.close() 感到困惑[不是 file.close()]。 或者,根本不调用它?会不会漏气? 至于来自 document 的示例
我正在我的大学上操作系统类(class),我们的任务之一是使用 mmap 实现简单的 malloc。现在我开始工作了,我尝试使用 valgrind 来检测遗留的任何错误。不管是否释放内存,valgri
有谁知道 mmap(2) 和 mmap(3) 的区别是什么?手册第 3 节被描述为“本章描述了除第 2 章中描述的实现系统调用的库函数之外的所有库函数。” mmap(3) 不执行系统调用吗? 阅读这两
我不知道我在理解mmap时错过了哪些知识。我就是想不通。但让我这样问我的问题: 我有很多(例如 3 个)文件 block ,其大小分别为 s1、s2、s3。 s1、s2 和 s3 均小于 Mmap (
在 Linux 下: #free -m total used free shared buffers cachedMem:
我正在尝试将 C 库(beaglebone PRU 驱动程序 prussdrv.c)与 Python 连接。我想要访问的特定函数返回一个 mmap 指针,如下所示: int __prussdrv_me
当我调用mmap时: ptr = mmap(NULL, ...); 并要求系统提供一个缓冲区并将文件映射到其中,然后使用 再次调用 mmap ptr2 = mmap(ptr, ...); 尝试
在 Android 上用 Java 内存映射一个大文件效果很好。但是当映射总数超过 ~1.5GB 时,即使有多个映射调用,它也会失败: mmap failed: ENOMEM (Out of memo
我在具有 64G 内存和大量磁盘空间的 debian-64 上运行一个专门的数据库守护进程。它使用磁盘上的哈希表(mmaped)并通过定期 write() 调用将实际数据写入文件。当进行大量更新时,m
C++代码: #include #include #include #include #include using namespace std; #define FILE_MODE (S_I
我想处理一个由 4Kb block 组成的文件。 随着事情的发生,我将编写更多数据并映射新部分,取消映射我不再需要的部分。 当要映射的文件数据总量约为 4Gb 时,仅 4Kb 的 map() 是否太小
大家好,我正在尝试将下面的代码转换为 python(访问树莓派 1Mhz 计时器),我不知道什么时候要映射对象,我们需要 + TIMER_OFFSET (timer = (long long int
我所做的是一个垃圾收集器,使用mmap(2)为用户空间分配空间,这就要求最初分配时可以从任何地方开始,但是后面的分配地址应该是与之前的分配连续,如下所示: page_size = getpagesiz
众所周知,最重要的 mmap() 功能是在许多进程之间共享文件映射。但众所周知,每个进程都有自己的地址空间。 问题是内存映射文件(更具体地说,它的数据)真正保存在哪里,以及进程如何访问这些内存? 我的
什么限制了内存映射文件的大小?我知道它不能大于未分配地址空间的最大连续块,并且应该有足够的可用磁盘空间。但是还有其他限制吗? 最佳答案 您太保守了:内存映射文件可能大于地址空间。 查看 内存映射文件的
如果我使用 mmap 来编写 uint32_t,我会遇到大端/小端约定的问题吗?特别是,如果我在 big-endian 机器上写入一些数据 mmap,当我尝试在 little-endian 机器上读取
所以,对于我最后一年的项目,我使用 Video4Linux2 从相机中提取 YUV420 图像,将它们解析为 x264(本地使用这些图像),然后通过 Live555 将编码流发送到 RTP/RTCP通
是 mmap在它们的效果中调用原子? 也就是说,是否由 mmap 进行了映射更改以原子方式出现在访问受影响区域的其他线程中? 作为试金石,请考虑您执行 mmap 的情况。在一个全为零的文件中(来自线程
我是一名优秀的程序员,十分优秀!