MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ff_mmap

Function ff_mmap

lib/ff_host_interface.c:53–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51extern int ff_mem_free_addr(void* p);
52
53void *
54ff_mmap(void *addr, uint64_t len, int prot, int flags, int fd, uint64_t offset)
55{
56 //return rte_malloc("", len, 4096);
57 int host_prot;
58 int host_flags;
59
60#ifdef FF_USE_PAGE_ARRAY
61 if( len == 4096 ){
62 return ff_mem_get_page();
63 }
64 else
65#endif
66 {
67
68 assert(ff_PROT_NONE == PROT_NONE);
69 host_prot = 0;
70 if ((prot & ff_PROT_READ) == ff_PROT_READ) host_prot |= PROT_READ;
71 if ((prot & ff_PROT_WRITE) == ff_PROT_WRITE) host_prot |= PROT_WRITE;
72
73 host_flags = 0;
74 if ((flags & ff_MAP_SHARED) == ff_MAP_SHARED) host_flags |= MAP_SHARED;
75 if ((flags & ff_MAP_PRIVATE) == ff_MAP_PRIVATE) host_flags |= MAP_PRIVATE;
76 if ((flags & ff_MAP_ANON) == ff_MAP_ANON) host_flags |= MAP_ANON;
77
78 void *ret = (mmap(addr, len, host_prot, host_flags, fd, offset));
79
80 if (ret == MAP_FAILED) {
81 ff_log(FF_LOG_ERR, FF_LOGTYPE_FSTACK_LIB, "fst mmap failed:%s\n", strerror(errno));
82 exit(1);
83 }
84 return ret;
85 }
86}
87
88int
89ff_munmap(void *addr, uint64_t len)

Callers 1

kmem_mallocFunction · 0.85

Calls 2

ff_mem_get_pageFunction · 0.85
ff_logFunction · 0.85

Tested by

no test coverage detected