Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: remove unnecessary V8 flag #123

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions deps/openssl/openssl/crypto/rand/rand_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,45 +356,6 @@ static ssize_t syscall_random(void *buf, size_t buflen)
* between size_t and ssize_t is safe even without a range check.
*/

/*
* Do runtime detection to find getentropy().
*
* Known OSs that should support this:
* - Darwin since 16 (OSX 10.12, IOS 10.0).
* - Solaris since 11.3
* - OpenBSD since 5.6
* - Linux since 3.17 with glibc 2.25
* - FreeBSD since 12.0 (1200061)
*
* Note: Sometimes getentropy() can be provided but not implemented
* internally. So we need to check errno for ENOSYS
*/
# if defined(__GNUC__) && __GNUC__>=2 && defined(__ELF__) && !defined(__hpux)
extern int getentropy(void *buffer, size_t length) __attribute__((weak));

if (getentropy != NULL) {
if (getentropy(buf, buflen) == 0)
return (ssize_t)buflen;
if (errno != ENOSYS)
return -1;
}
# else
union {
void *p;
int (*f)(void *buffer, size_t length);
} p_getentropy;

/*
* We could cache the result of the lookup, but we normally don't
* call this function often.
*/
ERR_set_mark();
p_getentropy.p = DSO_global_lookup("getentropy");
ERR_pop_to_mark();
if (p_getentropy.p != NULL)
return p_getentropy.f(buf, buflen) == 0 ? (ssize_t)buflen : -1;
# endif

/* Linux supports this since version 3.17 */
# if defined(__linux) && defined(__NR_getrandom)
return syscall(__NR_getrandom, buf, buflen, 0);
Expand Down
7 changes: 6 additions & 1 deletion deps/uv/include/uv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ enum uv_process_flags {
struct uv_process_s {
UV_HANDLE_FIELDS
uv_exit_cb exit_cb;
int pid;
uv_pid_t pid;
UV_PROCESS_PRIVATE_FIELDS
};

Expand All @@ -1067,6 +1067,7 @@ UV_EXTERN int uv_spawn(uv_loop_t* loop,
UV_EXTERN int uv_process_kill(uv_process_t*, int signum);
UV_EXTERN int uv_kill(int pid, int signum);
UV_EXTERN uv_pid_t uv_process_get_pid(const uv_process_t*);
UV_EXTERN uv_pid_t uv__waitpid(uv_pid_t pid, int *status, int options);


/*
Expand Down Expand Up @@ -1198,7 +1199,9 @@ typedef struct {
uint64_t ru_nivcsw; /* involuntary context switches */
} uv_rusage_t;

#ifndef __Fuchsia__
UV_EXTERN int uv_getrusage(uv_rusage_t* rusage);
#endif

UV_EXTERN int uv_os_homedir(char* buffer, size_t* size);
UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size);
Expand All @@ -1224,8 +1227,10 @@ UV_EXTERN uv_pid_t uv_os_getppid(void);
# define UV_PRIORITY_HIGHEST -20
#endif

#ifndef __Fuchsia__
UV_EXTERN int uv_os_getpriority(uv_pid_t pid, int* priority);
UV_EXTERN int uv_os_setpriority(uv_pid_t pid, int priority);
#endif

UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count);
UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count);
Expand Down
7 changes: 7 additions & 0 deletions deps/uv/include/uv/unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
# include "uv/posix.h"
#elif defined(__QNX__)
# include "uv/posix.h"
#elif defined(__Fuchsia__)
# include "uv/posix.h"
# include <zircon/types.h>
#endif

#ifndef NI_MAXHOST
Expand Down Expand Up @@ -128,7 +131,11 @@ typedef struct uv_buf_t {
typedef int uv_file;
typedef int uv_os_sock_t;
typedef int uv_os_fd_t;
#ifdef __Fuchsia__
typedef zx_handle_t uv_pid_t;
#else
typedef pid_t uv_pid_t;
#endif

#define UV_ONCE_INIT PTHREAD_ONCE_INIT

Expand Down
9 changes: 6 additions & 3 deletions deps/uv/src/unix/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
#include <arpa/inet.h>
#include <limits.h> /* INT_MAX, PATH_MAX, IOV_MAX */
#include <sys/uio.h> /* writev */
#ifndef __Fuchsia__
#include <sys/resource.h> /* getrusage */
#endif
#include <pwd.h>
#include <sys/utsname.h>
#include <sys/time.h>
Expand Down Expand Up @@ -966,6 +968,7 @@ int uv__fd_exists(uv_loop_t* loop, int fd) {
}


#ifndef __Fuchsia__
int uv_getrusage(uv_rusage_t* rusage) {
struct rusage usage;

Expand Down Expand Up @@ -997,7 +1000,7 @@ int uv_getrusage(uv_rusage_t* rusage) {

return 0;
}

#endif // !__Fuchsia__

int uv__open_cloexec(const char* path, int flags) {
#if defined(O_CLOEXEC)
Expand Down Expand Up @@ -1402,7 +1405,7 @@ uv_pid_t uv_os_getppid(void) {
return getppid();
}


#ifndef __Fuchsia__
int uv_os_getpriority(uv_pid_t pid, int* priority) {
int r;

Expand All @@ -1429,7 +1432,7 @@ int uv_os_setpriority(uv_pid_t pid, int priority) {

return 0;
}

#endif // !__Fuchsia__

int uv_os_uname(uv_utsname_t* buffer) {
struct utsname buf;
Expand Down
69 changes: 69 additions & 0 deletions deps/uv/src/unix/fuchsia.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#include "uv.h"
#include "internal.h"

#include <assert.h>
#include <string.h>

#include <zircon/syscalls.h>

int uv_exepath(char* buffer, size_t* size) {
if (buffer == NULL || size == NULL || *size == 0) return UV_EINVAL;
const char* path = "/pkg/";
if (*size < strlen(path) + 1) return UV_EINVAL;
strcpy(buffer, "/pkg/");
return 0;
}

void uv_loadavg(double avg[3]) {
// Not implemented. As in the case of Windows, it returns [0, 0, 0].
avg[0] = avg[1] = avg[2] = 0;
}

int uv_uptime(double* uptime) {
if (uptime == NULL) return UV_EINVAL;
// TODO(victor): This is the number of nanoseconds since the system was
// powered on. It does not always reset on reboot and does not adjust during
// sleep, and thus should not be used as a reliable source of uptime.
zx_time_t time_ns = zx_clock_get_monotonic();
*uptime = time_ns / 1000000000.0; // in seconds
return 0;
}

int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
*cpu_infos = NULL;
*count = 0;
return UV_ENOSYS;
}

uint64_t uv_get_free_memory(void) {
assert(0 && "uv_get_free_memory not supported on Fuchsia.");
return 0;
}

uint64_t uv_get_constrained_memory(void) {
assert(0 && "uv_get_constrained_memory not supported on Fuchsia.");
return 0;
}

uint64_t uv_get_total_memory(void) {
assert(0 && "uv_get_total_memory not supported on Fuchsia.");
return 0;
}

int uv_resident_set_memory(size_t* rss) {
assert(0 && "uv_resident_set_memory not supported on Fuchsia.");
return 0;
}

int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
*count = 0;
*addresses = NULL;
return UV_ENOSYS;
}

void uv_free_interface_addresses(uv_interface_address_t* addresses, int count) {
for (int i = 0; i < count; i++) {
uv__free(addresses[i].name);
}
uv__free(addresses);
}
2 changes: 1 addition & 1 deletion deps/uv/src/unix/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int uv_loop_init(uv_loop_t* loop) {
uv__loop_internal_fields_t* lfields;
void* saved_data;
int err;


saved_data = loop->data;
memset(loop, 0, sizeof(*loop));
Expand Down
6 changes: 6 additions & 0 deletions deps/uv/src/unix/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,17 @@ int uv_pipe_open(uv_pipe_t* handle, uv_file fd) {
return err;
#endif /* defined(__APPLE__) */

#ifdef __Fuchsia__
// TODO(victor): fcntl is not returning the correct mode.
// As a temporary hack, we set both flags.
flags |= UV_HANDLE_READABLE | UV_HANDLE_WRITABLE;
#else
mode &= O_ACCMODE;
if (mode != O_WRONLY)
flags |= UV_HANDLE_READABLE;
if (mode != O_RDONLY)
flags |= UV_HANDLE_WRITABLE;
#endif

return uv__stream_open((uv_stream_t*)handle, fd, flags);
}
Expand Down
69 changes: 62 additions & 7 deletions deps/uv/src/unix/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
#include <fcntl.h>
#include <poll.h>

#ifdef __Fuchsia__
# include <lib/fdio/spawn.h>
# include <zircon/syscalls.h>
#endif

#if defined(__APPLE__) && !TARGET_OS_IPHONE
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
Expand All @@ -44,14 +49,38 @@ extern char **environ;
# include <grp.h>
#endif

uv_pid_t uv__waitpid(uv_pid_t pid, int *status, int options) {
#ifdef __Fuchsia__
// TODO(victor): ignoring options for now
assert(options == 0);

zx_status_t result = zx_object_wait_one(pid, ZX_TASK_TERMINATED, ZX_TIME_INFINITE, NULL);
if (result != ZX_OK)
goto error;

zx_info_process_t proc_info;
result = zx_object_get_info(pid, ZX_INFO_PROCESS, &proc_info, sizeof(proc_info), NULL, NULL);
if (result != ZX_OK)
goto error;

*status = proc_info.return_code;
return 0;

error:
errno = ECHILD;
return -1;
#else
return waitpid(pid, status, options);
#endif
}

static void uv__chld(uv_signal_t* handle, int signum) {
uv_process_t* process;
uv_loop_t* loop;
int exit_status;
int term_signal;
int status;
pid_t pid;
uv_pid_t pid;
QUEUE pending;
QUEUE* q;
QUEUE* h;
Expand All @@ -68,7 +97,7 @@ static void uv__chld(uv_signal_t* handle, int signum) {
q = QUEUE_NEXT(q);

do
pid = waitpid(process->pid, &status, WNOHANG);
pid = uv__waitpid(process->pid, &status, WNOHANG);
while (pid == -1 && errno == EINTR);

if (pid == 0)
Expand Down Expand Up @@ -183,6 +212,7 @@ static void uv__process_close_stream(uv_stdio_container_t* container) {
}


#ifndef __Fuchsia__
static void uv__write_int(int fd, int val) {
ssize_t n;

Expand All @@ -195,9 +225,10 @@ static void uv__write_int(int fd, int val) {

assert(n == sizeof(val));
}
#endif


#if !(defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH))
#if !(defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH)) && !defined(__Fuchsia__)
/* execvp is marked __WATCHOS_PROHIBITED __TVOS_PROHIBITED, so must be
* avoided. Since this isn't called on those targets, the function
* doesn't even need to be defined for them.
Expand Down Expand Up @@ -342,7 +373,6 @@ static void uv__process_child_init(const uv_process_options_t* options,
}
#endif


int uv_spawn(uv_loop_t* loop,
uv_process_t* process,
const uv_process_options_t* options) {
Expand All @@ -355,7 +385,7 @@ int uv_spawn(uv_loop_t* loop,
int (*pipes)[2];
int stdio_count;
ssize_t r;
pid_t pid;
uv_pid_t pid;
int err;
int exec_errorno;
int i;
Expand Down Expand Up @@ -424,6 +454,30 @@ int uv_spawn(uv_loop_t* loop,

/* Acquire write lock to prevent opening new fds in worker threads */
uv_rwlock_wrlock(&loop->cloexec_lock);

#ifdef __Fuchsia__
const char *executable_path;
if (*options->file == 0) {
// TODO(victor): This is not necessarilly the name of the process!!
executable_path = "/pkg/uv_tests";
} else {
executable_path = options->file;
}

// TODO(victor): missing uv_process_child_init logic before spawning.
char err_msg_out[FDIO_SPAWN_ERR_MSG_MAX_LENGTH];
zx_status_t zx_status = fdio_spawn_etc(ZX_HANDLE_INVALID, FDIO_SPAWN_CLONE_ALL, executable_path,
(const char* const *)options->args,
(const char* const *)options->env, 0, NULL,
&pid, err_msg_out);
if (zx_status != ZX_OK) {
err = UV__ERR(ENOENT);
uv_rwlock_wrunlock(&loop->cloexec_lock);
uv__close(signal_pipe[0]);
uv__close(signal_pipe[1]);
goto error;
}
#else
pid = fork();

if (pid == -1) {
Expand All @@ -438,6 +492,7 @@ int uv_spawn(uv_loop_t* loop,
uv__process_child_init(options, stdio_count, pipes, signal_pipe[1]);
abort();
}
#endif

/* Release lock in parent process */
uv_rwlock_wrunlock(&loop->cloexec_lock);
Expand All @@ -453,12 +508,12 @@ int uv_spawn(uv_loop_t* loop,
; /* okay, EOF */
else if (r == sizeof(exec_errorno)) {
do
err = waitpid(pid, &status, 0); /* okay, read errorno */
err = uv__waitpid(pid, &status, 0); /* okay, read errorno */
while (err == -1 && errno == EINTR);
assert(err == pid);
} else if (r == -1 && errno == EPIPE) {
do
err = waitpid(pid, &status, 0); /* okay, got EPIPE */
err = uv__waitpid(pid, &status, 0); /* okay, got EPIPE */
while (err == -1 && errno == EINTR);
assert(err == pid);
} else
Expand Down
Loading