NDN-DPDK
High-Speed Named Data Networking Forwarder
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
mmapfd.h
Go to the documentation of this file.
1 #ifndef NDNDPDK_CORE_MMAPFD_H
2 #define NDNDPDK_CORE_MMAPFD_H
3 
6 #include "common.h"
7 
9 typedef struct MmapFd {
10  void* map;
11  size_t size;
12  int fd;
14 
20 __attribute__((nonnull)) bool
21 MmapFd_Open(MmapFd* m, const char* filename, size_t size);
22 
28 __attribute__((nonnull)) bool
29 MmapFd_Close(MmapFd* m, const char* filename, size_t size);
30 
35 __attribute__((nonnull, returns_nonnull)) __rte_always_inline void*
36 MmapFd_At(const MmapFd* m, size_t pos) {
37  return RTE_PTR_ADD(m->map, pos);
38 }
39 
40 #endif // NDNDPDK_CORE_MMAPFD_H
bool MmapFd_Open(MmapFd *m, const char *filename, size_t size)
Create a file with memory map.
Definition: mmapfd.c:20
bool MmapFd_Close(MmapFd *m, const char *filename, size_t size)
Close a file with memory map.
Definition: mmapfd.c:55
__rte_always_inline void * MmapFd_At(const MmapFd *m, size_t pos)
Access mapped memory region.
Definition: mmapfd.h:36
struct MmapFd MmapFd
Memory map and file descriptor.
Memory map and file descriptor.
Definition: mmapfd.h:9
void * map
Definition: mmapfd.h:10
size_t size
Definition: mmapfd.h:11
int fd
Definition: mmapfd.h:12