Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
unique-xids
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
unique-xids
Commits
9c9ce2a6
Commit
9c9ce2a6
authored
Mar 11, 2011
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the power-of-two rounding functions generally available and
use them for VSM allocation
parent
b530ed43
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
7 deletions
+9
-7
common.h
bin/varnishd/common.h
+8
-0
storage_persistent.h
bin/varnishd/storage_persistent.h
+0
-5
vsm.c
bin/varnishd/vsm.c
+1
-2
No files found.
bin/varnishd/common.h
View file @
9c9ce2a6
...
...
@@ -93,3 +93,11 @@ void vsm_iter_n(struct vsm_chunk **pp);
/* cache_lck.c */
struct
lock
{
void
*
priv
;
};
// Opaque
/*---------------------------------------------------------------------
* Generic power-2 rounding macros
*/
#define PWR2(x) ((((x)-1)&(x))==0)
/* Is a power of two */
#define RDN2(x, y) ((x)&(~((y)-1)))
/* if y is powers of two */
#define RUP2(x, y) (((x)+((y)-1))&(~((y)-1)))
/* if y is powers of two */
bin/varnishd/storage_persistent.h
View file @
9c9ce2a6
...
...
@@ -148,11 +148,6 @@ struct smp_sc {
/*--------------------------------------------------------------------*/
/* Generic power-2 rounding */
#define PWR2(x) ((((x)-1)&(x))==0)
/* Is a power of two */
#define RDN2(x, y) ((x)&(~((y)-1)))
/* if y is powers of two */
#define RUP2(x, y) (((x)+((y)-1))&(~((y)-1)))
/* if y is powers of two */
/* Pointer round up/down & assert */
#define PRNDN(sc, x) ((void*)RDN2((uintptr_t)(x), sc->align))
#define PRNUP(sc, x) ((void*)RUP2((uintptr_t)(x), sc->align))
...
...
bin/varnishd/vsm.c
View file @
9c9ce2a6
...
...
@@ -165,8 +165,7 @@ VSM_Alloc(unsigned size, const char *class, const char *type, const char *ident)
vsm_cleanup
();
/* Round up to pointersize */
size
+=
sizeof
(
void
*
)
-
1
;
size
&=
~
(
sizeof
(
void
*
)
-
1
);
size
=
RUP2
(
size
,
sizeof
(
void
*
));
size
+=
sizeof
*
sha
;
/* Make space for the header */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment