Skip to content

Commit

Permalink
P2Pool fixes
Browse files Browse the repository at this point in the history
- Removed `dlsym` dependency
- Removed `GetSystemTimePreciseAsFileTime` dependency
  • Loading branch information
SChernykh committed Aug 31, 2023
1 parent f0bb7e4 commit 26d43f4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 46 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ set(uv_sources
src/version.c)

if(WIN32)
list(APPEND uv_defines WIN32_LEAN_AND_MEAN _WIN32_WINNT=0x0602)
list(APPEND uv_defines WIN32_LEAN_AND_MEAN _WIN32_WINNT=0x0600)
list(APPEND uv_libraries
psapi
user32
Expand Down
44 changes: 0 additions & 44 deletions src/unix/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,31 +290,8 @@ static ssize_t uv__fs_mkdtemp(uv_fs_t* req) {
}


static int (*uv__mkostemp)(char*, int);


static void uv__mkostemp_initonce(void) {
/* z/os doesn't have RTLD_DEFAULT but that's okay
* because it doesn't have mkostemp(O_CLOEXEC) either.
*/
#ifdef RTLD_DEFAULT
uv__mkostemp = (int (*)(char*, int)) dlsym(RTLD_DEFAULT, "mkostemp");

/* We don't care about errors, but we do want to clean them up.
* If there has been no error, then dlerror() will just return
* NULL.
*/
dlerror();
#endif /* RTLD_DEFAULT */
}


static int uv__fs_mkstemp(uv_fs_t* req) {
static uv_once_t once = UV_ONCE_INIT;
int r;
#ifdef O_CLOEXEC
static _Atomic int no_cloexec_support;
#endif
static const char pattern[] = "XXXXXX";
static const size_t pattern_size = sizeof(pattern) - 1;
char* path;
Expand All @@ -335,27 +312,6 @@ static int uv__fs_mkstemp(uv_fs_t* req) {
goto clobber;
}

uv_once(&once, uv__mkostemp_initonce);

#ifdef O_CLOEXEC
if (atomic_load_explicit(&no_cloexec_support, memory_order_relaxed) == 0 &&
uv__mkostemp != NULL) {
r = uv__mkostemp(path, O_CLOEXEC);

if (r >= 0)
return r;

/* If mkostemp() returns EINVAL, it means the kernel doesn't
support O_CLOEXEC, so we just fallback to mkstemp() below. */
if (errno != EINVAL)
goto clobber;

/* We set the static variable so that next calls don't even
try to use mkostemp. */
atomic_store_explicit(&no_cloexec_support, 1, memory_order_relaxed);
}
#endif /* O_CLOEXEC */

if (req->cb != NULL)
uv_rwlock_rdlock(&req->loop->cloexec_lock);

Expand Down
2 changes: 1 addition & 1 deletion src/win/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ int uv_clock_gettime(uv_clock_id clock_id, uv_timespec64_t* ts) {
ts->tv_nsec = t % 1000000000;
return 0;
case UV_CLOCK_REALTIME:
GetSystemTimePreciseAsFileTime(&ft);
GetSystemTimeAsFileTime(&ft);
/* In 100-nanosecond increments from 1601-01-01 UTC because why not? */
t = (int64_t) ft.dwHighDateTime << 32 | ft.dwLowDateTime;
/* Convert to UNIX epoch, 1970-01-01. Still in 100 ns increments. */
Expand Down

0 comments on commit 26d43f4

Please sign in to comment.