Welcome! Log In Create A New Profile

Advanced

[njs] Masks definition corrected and made regularized.

Vadim Zhestikov via nginx-devel
November 14, 2022 08:34PM
details: https://hg.nginx.org/njs/rev/993f19791a71
branches:
changeset: 1998:993f19791a71
user: Vadim Zhestikov <v.zhestikov@f5.com>
date: Mon Nov 14 17:31:03 2022 -0800
description:
Masks definition corrected and made regularized.

diffstat:

src/njs_scope.h | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)

diffs (57 lines):

diff -r 283ae119d121 -r 993f19791a71 src/njs_scope.h
--- a/src/njs_scope.h Mon Nov 14 09:18:37 2022 -0800
+++ b/src/njs_scope.h Mon Nov 14 17:31:03 2022 -0800
@@ -7,12 +7,20 @@
#ifndef _NJS_SCOPE_H_INCLUDED_
#define _NJS_SCOPE_H_INCLUDED_

-
+#define NJS_SCOPE_VAR_OFFSET 0
#define NJS_SCOPE_VAR_SIZE 4
-#define NJS_SCOPE_TYPE_OFFSET (NJS_SCOPE_VAR_SIZE + 4)
-#define NJS_SCOPE_VALUE_OFFSET (NJS_SCOPE_TYPE_OFFSET + 1)
-#define NJS_SCOPE_VALUE_MAX ((1 << (32 - NJS_SCOPE_VALUE_OFFSET)) - 1)
-#define NJS_SCOPE_TYPE_MASK ((NJS_SCOPE_VALUE_MAX) << NJS_SCOPE_VAR_SIZE)
+
+#define NJS_SCOPE_TYPE_OFFSET (NJS_SCOPE_VAR_OFFSET + NJS_SCOPE_VAR_SIZE)
+#define NJS_SCOPE_TYPE_SIZE 4
+
+#define NJS_SCOPE_VALUE_OFFSET (NJS_SCOPE_TYPE_OFFSET + NJS_SCOPE_TYPE_SIZE)
+#define NJS_SCOPE_VALUE_SIZE 24
+
+#define NJS_SCOPE_VALUE_MASK ((1 << NJS_SCOPE_VALUE_SIZE) - 1)
+#define NJS_SCOPE_VAR_MASK ((1 << NJS_SCOPE_VAR_SIZE) - 1)
+#define NJS_SCOPE_TYPE_MASK ((1 << NJS_SCOPE_TYPE_SIZE) - 1)
+
+#define NJS_SCOPE_VALUE_MAX NJS_SCOPE_VALUE_MASK

#define NJS_INDEX_NONE ((njs_index_t) 0)
#define NJS_INDEX_ERROR ((njs_index_t) -1)
@@ -41,7 +49,7 @@ njs_scope_index(njs_scope_t scope, njs_i
type = NJS_LEVEL_GLOBAL;
}

- return (index << NJS_SCOPE_VALUE_OFFSET) | (type << NJS_SCOPE_VAR_SIZE)
+ return (index << NJS_SCOPE_VALUE_OFFSET) | (type << NJS_SCOPE_TYPE_OFFSET)
| var_type;
}

@@ -49,15 +57,15 @@ njs_scope_index(njs_scope_t scope, njs_i
njs_inline njs_variable_type_t
njs_scope_index_var(njs_index_t index)
{
- return (njs_variable_type_t) (index & ~NJS_SCOPE_TYPE_MASK);
+ return (njs_variable_type_t) (index & NJS_SCOPE_VAR_MASK);
}


njs_inline njs_level_type_t
njs_scope_index_type(njs_index_t index)
{
- return (njs_level_type_t) ((index >> NJS_SCOPE_VAR_SIZE)
- & ~NJS_SCOPE_TYPE_MASK);
+ return (njs_level_type_t) ((index >> NJS_SCOPE_TYPE_OFFSET)
+ & NJS_SCOPE_TYPE_MASK);
}


_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[njs] Masks definition corrected and made regularized.

Vadim Zhestikov via nginx-devel 191 November 14, 2022 08:34PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 88
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready