aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2016-02-04 18:30:21 +0300
committerMaxim Dounin <mdounin@mdounin.ru>2016-02-04 18:30:21 +0300
commit86cc342a26af3aa677d9770dc6a9bcdbd07f5a9e (patch)
tree679e72e4809e5e5641cd697be00cc5f206553aa0 /src/os/unix
parent0f67d6355cb365983820d3c268e25424509b2ef6 (diff)
downloadnginx-86cc342a26af3aa677d9770dc6a9bcdbd07f5a9e.tar.gz
nginx-86cc342a26af3aa677d9770dc6a9bcdbd07f5a9e.zip
Dynamic modules: dlopen() support.
Diffstat (limited to 'src/os/unix')
-rw-r--r--src/os/unix/ngx_darwin_config.h2
-rw-r--r--src/os/unix/ngx_dlopen.c28
-rw-r--r--src/os/unix/ngx_dlopen.h31
-rw-r--r--src/os/unix/ngx_freebsd_config.h2
-rw-r--r--src/os/unix/ngx_linux_config.h2
-rw-r--r--src/os/unix/ngx_posix_config.h5
-rw-r--r--src/os/unix/ngx_solaris_config.h2
7 files changed, 72 insertions, 0 deletions
diff --git a/src/os/unix/ngx_darwin_config.h b/src/os/unix/ngx_darwin_config.h
index bbad977cb..cfe3ce223 100644
--- a/src/os/unix/ngx_darwin_config.h
+++ b/src/os/unix/ngx_darwin_config.h
@@ -48,6 +48,8 @@
#include <sys/sysctl.h>
#include <xlocale.h>
+#include <dlfcn.h>
+
#ifndef IOV_MAX
#define IOV_MAX 64
diff --git a/src/os/unix/ngx_dlopen.c b/src/os/unix/ngx_dlopen.c
new file mode 100644
index 000000000..a0efc6925
--- /dev/null
+++ b/src/os/unix/ngx_dlopen.c
@@ -0,0 +1,28 @@
+
+/*
+ * Copyright (C) Maxim Dounin
+ * Copyright (C) Nginx, Inc.
+ */
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+#if (NGX_HAVE_DLOPEN)
+
+char *
+ngx_dlerror(void)
+{
+ char *err;
+
+ err = (char *) dlerror();
+
+ if (err == NULL) {
+ return "";
+ }
+
+ return err;
+}
+
+#endif
diff --git a/src/os/unix/ngx_dlopen.h b/src/os/unix/ngx_dlopen.h
new file mode 100644
index 000000000..7a3159f43
--- /dev/null
+++ b/src/os/unix/ngx_dlopen.h
@@ -0,0 +1,31 @@
+
+/*
+ * Copyright (C) Maxim Dounin
+ * Copyright (C) Nginx, Inc.
+ */
+
+
+#ifndef _NGX_DLOPEN_H_INCLUDED_
+#define _NGX_DLOPEN_H_INCLUDED_
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+#define ngx_dlopen(path) dlopen((char *) path, RTLD_NOW | RTLD_GLOBAL)
+#define ngx_dlopen_n "dlopen()"
+
+#define ngx_dlsym(handle, symbol) dlsym(handle, symbol)
+#define ngx_dlsym_n "dlsym()"
+
+#define ngx_dlclose(handle) dlclose(handle)
+#define ngx_dlclose_n "dlclose()"
+
+
+#if (NGX_HAVE_DLOPEN)
+char *ngx_dlerror(void);
+#endif
+
+
+#endif /* _NGX_DLOPEN_H_INCLUDED_ */
diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h
index 9a2578875..b7da48cb1 100644
--- a/src/os/unix/ngx_freebsd_config.h
+++ b/src/os/unix/ngx_freebsd_config.h
@@ -49,6 +49,8 @@
#include <osreldate.h>
#include <sys/sysctl.h>
+#include <dlfcn.h>
+
#if __FreeBSD_version < 400017
diff --git a/src/os/unix/ngx_linux_config.h b/src/os/unix/ngx_linux_config.h
index 162a992c9..2f6129d88 100644
--- a/src/os/unix/ngx_linux_config.h
+++ b/src/os/unix/ngx_linux_config.h
@@ -55,6 +55,8 @@
#include <crypt.h>
#include <sys/utsname.h> /* uname() */
+#include <dlfcn.h>
+
#include <ngx_auto_config.h>
diff --git a/src/os/unix/ngx_posix_config.h b/src/os/unix/ngx_posix_config.h
index 443c4b001..bf75997f6 100644
--- a/src/os/unix/ngx_posix_config.h
+++ b/src/os/unix/ngx_posix_config.h
@@ -108,6 +108,11 @@
#include <ngx_auto_config.h>
+#if (NGX_HAVE_DLOPEN)
+#include <dlfcn.h>
+#endif
+
+
#if (NGX_HAVE_POSIX_SEM)
#include <semaphore.h>
#endif
diff --git a/src/os/unix/ngx_solaris_config.h b/src/os/unix/ngx_solaris_config.h
index ddfd98457..ffa01c8b7 100644
--- a/src/os/unix/ngx_solaris_config.h
+++ b/src/os/unix/ngx_solaris_config.h
@@ -55,6 +55,8 @@
#include <inttypes.h>
#include <crypt.h>
+#include <dlfcn.h>
+
#define NGX_ALIGNMENT _MAX_ALIGNMENT
#include <ngx_auto_config.h>