Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit 18aee9e

Browse files
committed
Remove unused syscalls
1 parent 83370e2 commit 18aee9e

File tree

3 files changed

+0
-84
lines changed

3 files changed

+0
-84
lines changed

omniscidb/OSDependent/Unix/omnisci_fs.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,32 +35,6 @@ size_t file_size(const int fd) {
3535
return buf.st_size;
3636
}
3737

38-
void* checked_mmap(const int fd, const size_t sz) {
39-
auto ptr = mmap(nullptr, sz, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0);
40-
CHECK(ptr != reinterpret_cast<void*>(-1));
41-
#ifdef __linux__
42-
#ifdef MADV_HUGEPAGE
43-
madvise(ptr, sz, MADV_RANDOM | MADV_WILLNEED | MADV_HUGEPAGE);
44-
#else
45-
madvise(ptr, sz, MADV_RANDOM | MADV_WILLNEED);
46-
#endif
47-
#endif
48-
return ptr;
49-
}
50-
51-
void checked_munmap(void* addr, size_t length) {
52-
CHECK_EQ(0, munmap(addr, length));
53-
}
54-
55-
int msync(void* addr, size_t length, bool async) {
56-
// TODO: support MS_INVALIDATE?
57-
return ::msync(addr, length, async ? MS_ASYNC : MS_SYNC);
58-
}
59-
60-
int fsync(int fd) {
61-
return ::fsync(fd);
62-
}
63-
6438
int open(const char* path, int flags, int mode) {
6539
return ::open(path, flags, mode);
6640
}
@@ -69,10 +43,6 @@ void close(const int fd) {
6943
::close(fd);
7044
}
7145

72-
::FILE* fopen(const char* filename, const char* mode) {
73-
return ::fopen(filename, mode);
74-
}
75-
7646
::FILE* popen(const char* command, const char* type) {
7747
return ::popen(command, type);
7848
}

omniscidb/OSDependent/Windows/omnisci_fs.cpp

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,6 @@ size_t file_size(const int fd) {
3737
return buf.st_size;
3838
}
3939

40-
void* checked_mmap(const int fd, const size_t sz) {
41-
auto handle = _get_osfhandle(fd);
42-
HANDLE map_handle =
43-
CreateFileMapping(reinterpret_cast<HANDLE>(handle), NULL, PAGE_READWRITE, 0, 0, 0);
44-
CHECK(map_handle);
45-
auto map_ptr = MapViewOfFile(map_handle, FILE_MAP_WRITE | FILE_MAP_READ, 0, 0, sz);
46-
CHECK(map_ptr);
47-
CHECK(CloseHandle(map_handle) != 0);
48-
return map_ptr;
49-
}
50-
51-
void checked_munmap(void* addr, size_t length) {
52-
CHECK(UnmapViewOfFile(addr) != 0);
53-
}
54-
55-
int msync(void* addr, size_t length, bool async) {
56-
auto err = FlushViewOfFile(addr, length);
57-
return err != 0 ? 0 : -1;
58-
}
59-
60-
int fsync(int fd) {
61-
// TODO: FlushFileBuffers
62-
auto file = _fdopen(fd, "a+");
63-
return fflush(file);
64-
}
65-
6640
int open(const char* path, int flags, int mode) {
6741
return _open(path, flags, mode);
6842
}
@@ -71,24 +45,6 @@ void close(const int fd) {
7145
_close(fd);
7246
}
7347

74-
::FILE* fopen(const char* filename, const char* mode) {
75-
FILE* f;
76-
auto err = fopen_s(&f, filename, mode);
77-
// Handle 'too many open files' error
78-
if (err == EMFILE) {
79-
auto max_handles = _getmaxstdio();
80-
if (max_handles < 8192) {
81-
auto res = _setmaxstdio(8192);
82-
if (res < 0) {
83-
LOG(FATAL) << "Cannot increase maximum number of open files";
84-
}
85-
err = fopen_s(&f, filename, mode);
86-
}
87-
}
88-
CHECK(!err) << "ERROR [" << filename << ":" << mode << "[" << err << "]";
89-
return f;
90-
}
91-
9248
::FILE* popen(const char* command, const char* type) {
9349
return _popen(command, type);
9450
}

omniscidb/OSDependent/omnisci_fs.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,10 @@ namespace omnisci {
2424

2525
size_t file_size(const int fd);
2626

27-
void* checked_mmap(const int fd, const size_t sz);
28-
29-
void checked_munmap(void* addr, size_t length);
30-
31-
int msync(void* addr, size_t length, bool async);
32-
33-
int fsync(int fd);
34-
3527
int open(const char* path, int flags, int mode);
3628

3729
void close(const int fd);
3830

39-
::FILE* fopen(const char* filename, const char* mode);
40-
4131
::FILE* popen(const char* command, const char* type);
4232

4333
int32_t pclose(::FILE* fh);

0 commit comments

Comments
 (0)