Skip to content

Commit

Permalink
createMemoryFile for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
apangin committed May 7, 2024
1 parent 4c775ff commit 61be698
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/os_macos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <sys/sysctl.h>
#include <sys/time.h>
#include <sys/times.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include "os.h"
Expand Down Expand Up @@ -327,8 +328,13 @@ u64 OS::getTotalCpuTime(u64* utime, u64* stime) {
}

int OS::createMemoryFile(const char* name) {
// TODO: Use shm_open
return -1;
char buf[128];
snprintf(buf, sizeof(buf), "%.100s.%d", name, processId());
int fd = shm_open(buf, O_RDWR | O_CREAT | O_TRUNC, 0600);
if (fd >= 0) {
shm_unlink(buf);
}
return fd;
}

void OS::copyFile(int src_fd, int dst_fd, off_t offset, size_t size) {
Expand Down

0 comments on commit 61be698

Please sign in to comment.