Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to | ||
* deal in the Software without restriction, including without limitation the | ||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
* sell copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
*/ | ||
|
||
#include "uv.h" | ||
#include "internal.h" | ||
|
||
#include <dlfcn.h> | ||
#include <errno.h> | ||
|
||
|
||
const uv_err_t uv_ok_ = { UV_OK, 0 }; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
uv_err_t uv_dlopen(const char* filename, uv_lib_t* library) { | ||
void* handle = dlopen(filename, RTLD_LAZY); | ||
if (handle == NULL) { | ||
return uv__new_sys_error(errno); | ||
} | ||
|
||
*library = handle; | ||
return uv_ok_; | ||
} | ||
|
||
|
||
uv_err_t uv_dlclose(uv_lib_t library) { | ||
if (dlclose(library) != 0) { | ||
return uv__new_sys_error(errno); | ||
} | ||
|
||
return uv_ok_; | ||
} | ||
|
||
|
||
uv_err_t uv_dlsym(uv_lib_t library, const char* name, void** ptr) { | ||
void* address = dlsym(library, name); | ||
if (address == NULL) { | ||
return uv__new_sys_error(errno); | ||
} | ||
|
||
*ptr = (void*) address; | ||
return uv_ok_; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to | ||
* deal in the Software without restriction, including without limitation the | ||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
* sell copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
*/ | ||
|
||
#include "uv.h" | ||
#include "internal.h" | ||
|
||
|
||
uv_err_t uv_dlopen(const char* filename, uv_lib_t* library) { | ||
wchar_t filename_w[32768]; | ||
HMODULE handle; | ||
|
||
if (!uv_utf8_to_utf16(filename, | ||
filename_w, | ||
sizeof(filename_w) / sizeof(wchar_t))) { | ||
return uv__new_sys_error(GetLastError()); | ||
} | ||
|
||
handle = LoadLibraryW(filename_w); | ||
if (handle == NULL) { | ||
return uv__new_sys_error(GetLastError()); | ||
} | ||
|
||
*library = handle; | ||
return uv_ok_; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bnoordhuis
Contributor
|
||
} | ||
|
||
|
||
uv_err_t uv_dlclose(uv_lib_t library) { | ||
if (!FreeLibrary(library)) { | ||
return uv__new_sys_error(GetLastError()); | ||
} | ||
|
||
return uv_ok_; | ||
} | ||
|
||
|
||
uv_err_t uv_dlsym(uv_lib_t library, const char* name, void** ptr) { | ||
FARPROC proc = GetProcAddress(library, name); | ||
if (proc == NULL) { | ||
return uv__new_sys_error(GetLastError()); | ||
} | ||
|
||
*ptr = (void*) proc; | ||
return uv_ok_; | ||
} |
1 comment
on commit 16e0314
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diff --git a/config-unix.mk b/config-unix.mk
index 53bcbd4..9524061 100644
--- a/config-unix.mk
+++ b/config-unix.mk
@@ -28,6 +28,7 @@ CPPFLAGS += -D_LARGEFILE_SOURCE
CPPFLAGS += -D_FILE_OFFSET_BITS=64
OBJS += src/unix/core.o
+OBJS += src/unix/dl.o
OBJS += src/unix/fs.o
OBJS += src/unix/cares.o
OBJS += src/unix/udp.o
Make this static.