summaryrefslogtreecommitdiff
path: root/deps/uv/src/unix/core.c
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-08-09 11:03:55 -0400
committercjihrig <cjihrig@gmail.com>2019-08-11 11:22:01 -0400
commitce7f3ed13ca15ae4c166d922e7ee39ad2ef41abb (patch)
treef25ca8d612ee2bdfb78f2bac31439633dfb2bb3d /deps/uv/src/unix/core.c
parent8ef68e66d0465441a79a5dae22e480bf0d83ed25 (diff)
downloadandroid-node-v8-ce7f3ed13ca15ae4c166d922e7ee39ad2ef41abb.tar.gz
android-node-v8-ce7f3ed13ca15ae4c166d922e7ee39ad2ef41abb.tar.bz2
android-node-v8-ce7f3ed13ca15ae4c166d922e7ee39ad2ef41abb.zip
deps: upgrade to libuv 1.31.0
Notable changes: - UV_FS_O_FILEMAP has been added for faster access to memory mapped files on Windows. - uv_fs_mkdir() now returns UV_EINVAL for invalid filenames on Windows. It previously returned UV_ENOENT. - The uv_fs_statfs() API has been added. - The uv_os_environ() and uv_os_free_environ() APIs have been added. Fixes: https://github.com/nodejs/node/issues/28599 Fixes: https://github.com/nodejs/node/issues/28945 Fixes: https://github.com/nodejs/node/issues/29008 PR-URL: https://github.com/nodejs/node/pull/29070 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Diffstat (limited to 'deps/uv/src/unix/core.c')
-rw-r--r--deps/uv/src/unix/core.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c
index 202c75bbb5..f4b94e30cc 100644
--- a/deps/uv/src/unix/core.c
+++ b/deps/uv/src/unix/core.c
@@ -50,11 +50,15 @@
#endif
#ifdef __APPLE__
+# include <crt_externs.h>
# include <mach-o/dyld.h> /* _NSGetExecutablePath */
# include <sys/filio.h>
# if defined(O_CLOEXEC)
# define UV__O_CLOEXEC O_CLOEXEC
# endif
+# define environ (*_NSGetEnviron())
+#else
+extern char** environ;
#endif
#if defined(__DragonFly__) || \
@@ -1284,6 +1288,62 @@ int uv_translate_sys_error(int sys_errno) {
}
+int uv_os_environ(uv_env_item_t** envitems, int* count) {
+ int i, j, cnt;
+ uv_env_item_t* envitem;
+
+ *envitems = NULL;
+ *count = 0;
+
+ for (i = 0; environ[i] != NULL; i++);
+
+ *envitems = uv__calloc(i, sizeof(**envitems));
+
+ if (envitems == NULL)
+ return UV_ENOMEM;
+
+ for (j = 0, cnt = 0; j < i; j++) {
+ char* buf;
+ char* ptr;
+
+ if (environ[j] == NULL)
+ break;
+
+ buf = uv__strdup(environ[j]);
+ if (buf == NULL)
+ goto fail;
+
+ ptr = strchr(buf, '=');
+ if (ptr == NULL) {
+ uv__free(buf);
+ continue;
+ }
+
+ *ptr = '\0';
+
+ envitem = &(*envitems)[cnt];
+ envitem->name = buf;
+ envitem->value = ptr + 1;
+
+ cnt++;
+ }
+
+ *count = cnt;
+ return 0;
+
+fail:
+ for (i = 0; i < cnt; i++) {
+ envitem = &(*envitems)[cnt];
+ uv__free(envitem->name);
+ }
+ uv__free(*envitems);
+
+ *envitems = NULL;
+ *count = 0;
+ return UV_ENOMEM;
+}
+
+
int uv_os_getenv(const char* name, char* buffer, size_t* size) {
char* var;
size_t len;