summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_unit_sptr.h
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2018-08-06 17:27:33 +0300
committerMax Romanov <max.romanov@nginx.com>2018-08-06 17:27:33 +0300
commit1bb22d1e922c87d3c86c67bdce626767ee48fb5c (patch)
tree6e067a82b309c3a0d0f592f037f26d886a7f8c13 /src/nxt_unit_sptr.h
parentb6ce2da65c9c5229d744b2d964623b2d0f731ee9 (diff)
downloadunit-1bb22d1e922c87d3c86c67bdce626767ee48fb5c.tar.gz
unit-1bb22d1e922c87d3c86c67bdce626767ee48fb5c.tar.bz2
Unit application library.
Library now used in all language modules. Old 'nxt_app_*' code removed. See src/test/nxt_unit_app_test.c for usage sample.
Diffstat (limited to 'src/nxt_unit_sptr.h')
-rw-r--r--src/nxt_unit_sptr.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/nxt_unit_sptr.h b/src/nxt_unit_sptr.h
new file mode 100644
index 00000000..314416e4
--- /dev/null
+++ b/src/nxt_unit_sptr.h
@@ -0,0 +1,38 @@
+
+/*
+ * Copyright (C) NGINX, Inc.
+ */
+
+#ifndef _NXT_UNIT_SPTR_H_INCLUDED_
+#define _NXT_UNIT_SPTR_H_INCLUDED_
+
+
+#include <inttypes.h>
+#include <stddef.h>
+#include <string.h>
+
+#include "nxt_unit_typedefs.h"
+
+
+/* Serialized pointer. */
+union nxt_unit_sptr_u {
+ uint8_t base[1];
+ uint32_t offset;
+};
+
+
+static inline void
+nxt_unit_sptr_set(nxt_unit_sptr_t *sptr, void *ptr)
+{
+ sptr->offset = (uint8_t *) ptr - sptr->base;
+}
+
+
+static inline void *
+nxt_unit_sptr_get(nxt_unit_sptr_t *sptr)
+{
+ return sptr->base + sptr->offset;
+}
+
+
+#endif /* _NXT_UNIT_SPTR_H_INCLUDED_ */