diff options
| author | Paul Eggert | 2015-11-19 11:31:45 -0800 |
|---|---|---|
| committer | Paul Eggert | 2015-11-19 11:32:21 -0800 |
| commit | c8a972b0c3082edfcca4a85562224499f75bfe9b (patch) | |
| tree | 6266e9c2d1d168e49ef6de34e800435162cca2d4 /src/dynlib.c | |
| parent | 7cd728c813f2c472a2f6a0cb0c3fb3ee46c9d8ad (diff) | |
| download | emacs-c8a972b0c3082edfcca4a85562224499f75bfe9b.tar.gz emacs-c8a972b0c3082edfcca4a85562224499f75bfe9b.zip | |
Style fixes for indenting etc. in module code
This is mostly indenting and spacing changes. Also, remove
some unnecessary static decls instead of bothering to reindent them.
* src/module.h (EMACS_EXTERN_C_BEGIN): Remove, and do this inline,
as most other Emacs files do for this sort of thing.
Diffstat (limited to 'src/dynlib.c')
| -rw-r--r-- | src/dynlib.c | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/src/dynlib.c b/src/dynlib.c index fbc5f9b873b..491a08e0787 100644 --- a/src/dynlib.c +++ b/src/dynlib.c | |||
| @@ -26,63 +26,68 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 26 | 26 | ||
| 27 | #include "dynlib.h" | 27 | #include "dynlib.h" |
| 28 | 28 | ||
| 29 | /* | 29 | #if defined _WIN32 |
| 30 | * Windows systems | 30 | |
| 31 | */ | 31 | /* MS-Windows systems. */ |
| 32 | #if defined(_WIN32) | ||
| 33 | 32 | ||
| 34 | #include <windows.h> | 33 | #include <windows.h> |
| 35 | 34 | ||
| 36 | dynlib_handle_ptr dynlib_open (const char * path) | 35 | dynlib_handle_ptr |
| 36 | dynlib_open (const char *path) | ||
| 37 | { | 37 | { |
| 38 | 38 | ||
| 39 | return (dynlib_handle_ptr) LoadLibrary (path); | 39 | return (dynlib_handle_ptr) LoadLibrary (path); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | void * dynlib_sym (dynlib_handle_ptr h, const char * sym) | 42 | void * |
| 43 | dynlib_sym (dynlib_handle_ptr h, const char *sym) | ||
| 43 | { | 44 | { |
| 44 | return GetProcAddress ((HMODULE) h, sym); | 45 | return GetProcAddress ((HMODULE) h, sym); |
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | bool dynlib_addr (void *ptr, const char **path, const char **sym) | 48 | bool |
| 49 | dynlib_addr (void *ptr, const char **path, const char **sym) | ||
| 48 | { | 50 | { |
| 49 | return false; /* not implemented */ | 51 | return false; /* not implemented */ |
| 50 | } | 52 | } |
| 51 | 53 | ||
| 52 | const char * dynlib_error (void) | 54 | const char * |
| 55 | dynlib_error (void) | ||
| 53 | { | 56 | { |
| 54 | /* TODO: use GetLastError(), FormatMessage(), ... */ | 57 | /* TODO: use GetLastError(), FormatMessage(), ... */ |
| 55 | return "Can't load DLL"; | 58 | return "Can't load DLL"; |
| 56 | } | 59 | } |
| 57 | 60 | ||
| 58 | int dynlib_close (dynlib_handle_ptr h) | 61 | int |
| 62 | dynlib_close (dynlib_handle_ptr h) | ||
| 59 | { | 63 | { |
| 60 | return FreeLibrary ((HMODULE) h) != 0; | 64 | return FreeLibrary ((HMODULE) h) != 0; |
| 61 | } | 65 | } |
| 62 | 66 | ||
| 67 | #elif defined HAVE_UNISTD_H | ||
| 63 | 68 | ||
| 64 | /* | 69 | /* POSIX systems. */ |
| 65 | * POSIX systems | ||
| 66 | */ | ||
| 67 | #elif defined(HAVE_UNISTD_H) | ||
| 68 | 70 | ||
| 69 | #include <dlfcn.h> | 71 | #include <dlfcn.h> |
| 70 | 72 | ||
| 71 | dynlib_handle_ptr dynlib_open (const char * path) | 73 | dynlib_handle_ptr |
| 74 | dynlib_open (const char *path) | ||
| 72 | { | 75 | { |
| 73 | return dlopen (path, RTLD_LAZY); | 76 | return dlopen (path, RTLD_LAZY); |
| 74 | } | 77 | } |
| 75 | 78 | ||
| 76 | void * dynlib_sym (dynlib_handle_ptr h, const char * sym) | 79 | void * |
| 80 | dynlib_sym (dynlib_handle_ptr h, const char *sym) | ||
| 77 | { | 81 | { |
| 78 | return dlsym (h, sym); | 82 | return dlsym (h, sym); |
| 79 | } | 83 | } |
| 80 | 84 | ||
| 81 | bool dynlib_addr (void *ptr, const char **path, const char **sym) | 85 | bool |
| 86 | dynlib_addr (void *ptr, const char **path, const char **sym) | ||
| 82 | { | 87 | { |
| 83 | #ifdef HAVE_DLADDR | 88 | #ifdef HAVE_DLADDR |
| 84 | Dl_info info; | 89 | Dl_info info; |
| 85 | if (dladdr (ptr, &info) != 0 && info.dli_fname != NULL && info.dli_sname != NULL) | 90 | if (dladdr (ptr, &info) && info.dli_fname && info.dli_sname) |
| 86 | { | 91 | { |
| 87 | *path = info.dli_fname; | 92 | *path = info.dli_fname; |
| 88 | *sym = info.dli_sname; | 93 | *sym = info.dli_sname; |
| @@ -92,12 +97,14 @@ bool dynlib_addr (void *ptr, const char **path, const char **sym) | |||
| 92 | return false; | 97 | return false; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| 95 | const char * dynlib_error (void) | 100 | const char * |
| 101 | dynlib_error (void) | ||
| 96 | { | 102 | { |
| 97 | return dlerror (); | 103 | return dlerror (); |
| 98 | } | 104 | } |
| 99 | 105 | ||
| 100 | int dynlib_close (dynlib_handle_ptr h) | 106 | int |
| 107 | dynlib_close (dynlib_handle_ptr h) | ||
| 101 | { | 108 | { |
| 102 | return dlclose (h) == 0; | 109 | return dlclose (h) == 0; |
| 103 | } | 110 | } |