Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
e5d37823
Commit
e5d37823
authored
Mar 22, 2011
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alloc: dont clash with libc's fls, avoid void pointer arithmetic
parent
5caaeab8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
10 deletions
+10
-10
ccan/alloc/alloc.c
ccan/alloc/alloc.c
+4
-4
ccan/alloc/bitops.c
ccan/alloc/bitops.c
+2
-2
ccan/alloc/bitops.h
ccan/alloc/bitops.h
+2
-2
ccan/alloc/test/run.c
ccan/alloc/test/run.c
+1
-1
ccan/alloc/tiny.c
ccan/alloc/tiny.c
+1
-1
No files found.
ccan/alloc/alloc.c
View file @
e5d37823
...
...
@@ -124,7 +124,7 @@ static unsigned long bucket_to_size(unsigned int bucket)
*/
static
unsigned
int
size_to_bucket
(
unsigned
long
size
)
{
unsigned
int
base
=
fls
(
size
/
2
);
unsigned
int
base
=
a
fls
(
size
/
2
);
unsigned
long
overshoot
;
overshoot
=
size
-
(
1UL
<<
base
);
...
...
@@ -134,7 +134,7 @@ static unsigned int size_to_bucket(unsigned long size)
static
unsigned
int
small_page_bits
(
unsigned
long
poolsize
)
{
return
fls
(
poolsize
/
MAX_SMALL_PAGES
-
1
);
return
a
fls
(
poolsize
/
MAX_SMALL_PAGES
-
1
);
}
static
struct
page_header
*
from_pgnum
(
struct
header
*
head
,
...
...
@@ -313,7 +313,7 @@ static unsigned int find_free_bit(const unsigned long bitmap[])
unsigned
int
i
;
for
(
i
=
0
;
bitmap
[
i
]
==
-
1UL
;
i
++
);
return
(
i
*
BITS_PER_LONG
)
+
ffsl
(
~
bitmap
[
i
])
-
1
;
return
(
i
*
BITS_PER_LONG
)
+
a
ffsl
(
~
bitmap
[
i
])
-
1
;
}
/* How many elements can we fit in a page? */
...
...
@@ -422,7 +422,7 @@ static void del_large_from_small_free_list(struct header *head,
for
(
i
=
0
;
i
<
SMALL_PAGES_PER_LARGE_PAGE
;
i
++
)
{
del_from_list
(
head
,
&
head
->
small_free_list
,
(
struct
page_header
*
)((
char
*
)
ph
(
struct
page_header
*
)((
char
*
)
ph
+
(
i
<<
sp_bits
)),
sp_bits
);
}
...
...
ccan/alloc/bitops.c
View file @
e5d37823
...
...
@@ -5,7 +5,7 @@
#include <ccan/ilog/ilog.h>
#include <limits.h>
unsigned
int
fls
(
unsigned
long
val
)
unsigned
int
a
fls
(
unsigned
long
val
)
{
BUILD_ASSERT
(
sizeof
(
val
)
==
sizeof
(
u32
)
||
sizeof
(
val
)
==
sizeof
(
u64
));
if
(
sizeof
(
val
)
==
sizeof
(
u32
))
...
...
@@ -15,7 +15,7 @@ unsigned int fls(unsigned long val)
}
/* FIXME: Move to bitops. */
unsigned
int
ffsl
(
unsigned
long
val
)
unsigned
int
a
ffsl
(
unsigned
long
val
)
{
#if HAVE_BUILTIN_FFSL
/* This is significantly faster! */
...
...
ccan/alloc/bitops.h
View file @
e5d37823
#ifndef CCAN_ALLOC_BITOPS_H
#define CCAN_ALLOC_BITOPS_H
unsigned
int
fls
(
unsigned
long
val
);
unsigned
int
ffsl
(
unsigned
long
val
);
unsigned
int
a
fls
(
unsigned
long
val
);
unsigned
int
a
ffsl
(
unsigned
long
val
);
unsigned
int
popcount
(
unsigned
long
val
);
unsigned
long
align_up
(
unsigned
long
x
,
unsigned
long
align
);
#endif
/* CCAN_ALLOC_BITOPS_H */
ccan/alloc/test/run.c
View file @
e5d37823
...
...
@@ -11,7 +11,7 @@
static
int
addr_cmp
(
void
**
a
,
void
**
b
)
{
return
(
*
a
)
-
(
*
b
);
return
(
char
*
)(
*
a
)
-
(
char
*
)
(
*
b
);
}
static
bool
unique
(
void
*
p
[],
unsigned
int
num
)
...
...
ccan/alloc/tiny.c
View file @
e5d37823
...
...
@@ -19,7 +19,7 @@
/* Val is usually offset by MIN_BLOCK_SIZE here. */
static
unsigned
encode_length
(
unsigned
long
val
)
{
unsigned
int
bits
=
fls
(
val
);
unsigned
int
bits
=
a
fls
(
val
);
/* 5 bits in first byte. */
if
(
bits
<=
5
)
return
1
;
...
...
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