Minor fixes after the merge

Deleting some duplicate functions and header
This commit is contained in:
2026-04-28 18:06:35 +01:00
parent 0faf2bc792
commit 5cb47a17a2
2 changed files with 33 additions and 73 deletions

View File

@@ -10,7 +10,6 @@
// xxhash include
#define XXH_STATIC_LINKING_ONLY
#include "xxh_x86dispatch.h"
#include <ctype.h>
#include "config.h"
// ----------------------------- Globals ------------------------------------
@@ -71,7 +70,6 @@ double timer_elapsed(HiResTimer *t) {
// ------------------- Get HW info --------------------
#if defined(_WIN32) || defined(_WIN64)
size_t platform_physical_cores(void) {
DWORD len = 0;
GetLogicalProcessorInformation(NULL, &len);
@@ -89,12 +87,10 @@ size_t platform_physical_cores(void) {
}
#elif defined(__linux__)
size_t platform_physical_cores(void) {
long n = sysconf(_SC_NPROCESSORS_ONLN);
return n > 0 ? (size_t)n : 1;
}
#endif
const char *get_xxhash_instruction_set(void) {
@@ -173,7 +169,6 @@ static int os_file_read(FileHandle handle, void *buf, size_t count,
// File close function
static void os_file_close(FileHandle handle) { close(handle); }
#endif
// -------------------- Thread abstraction -------------------
@@ -292,7 +287,6 @@ static int thread_wait_multiple(Thread *threads, size_t count) {
}
return 0;
}
#endif
// ======================== Get file metadata ========================
@@ -739,39 +733,6 @@ void scan_folder(const char *base, ScannerContext *ctx) {
}
#elif defined(__linux__)
static int platform_get_file_times_fd(int dir_fd, const char *name,
time_t *created, time_t *modified) {
struct stat st;
if (fstatat(dir_fd, name, &st, 0) == 0) {
*created = st.st_ctime; // or st.st_birthtime on systems that support it
*modified = st.st_mtime;
return 0;
}
return -1;
}
static int platform_get_file_owner_fd(int dir_fd, const char *name, char *owner,
size_t owner_size) {
struct stat st;
if (fstatat(dir_fd, name, &st, 0) == 0) {
struct passwd pw;
struct passwd *result;
char buffer[4096]; // Sufficiently large buffer for passwd data
// Reentrant version (thread-safe)
if (getpwuid_r(st.st_uid, &pw, buffer, sizeof(buffer), &result) == 0 &&
result != NULL && result->pw_name != NULL) {
strncpy(owner, result->pw_name, owner_size - 1);
owner[owner_size - 1] = '\0';
} else {
// Fallback to uid
snprintf(owner, owner_size, "uid:%d", st.st_uid);
}
return 0;
}
return -1;
}
void scan_folder(const char *base, ScannerContext *ctx) {
PathBuilder pb;
path_builder_init(&pb, base);
@@ -903,7 +864,6 @@ void scan_folder(const char *base, ScannerContext *ctx) {
closedir(dir);
}
#endif
// ------------------------- Scan worker --------------------------------
@@ -1098,7 +1058,6 @@ typedef struct {
typedef IoUring *IoRingHandle;
typedef struct iovec IORING_BUFFER_INFO;
#define BUILD_READ_RETURN_VALUE int
#endif
typedef struct FileReadContext {
@@ -1651,7 +1610,7 @@ static int ioring_pop_completion(IoRingHandle ring, IoRingCQE *cqe) {
fprintf(
stderr,
"WARNING: I/O completion error for file '%s' - Error: %s (Code: %d)\n",
file_path, strerror(-res), ret);
file_path, strerror(-res), res);
}
return 1;
@@ -1671,7 +1630,6 @@ FileHandle ioring_open_file(FileEntry *fe) {
}
return handle;
}
#endif
// OS-agnostic helper macros