forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
powerpc: Use the new generic strncpy_from_user() and strnlen_user()
This is much the same as for SPARC except that we can do the find_zero() function more efficiently using the count-leading-zeroes instructions. Tested on 32-bit and 64-bit PowerPC. Signed-off-by: Paul Mackerras <[email protected]> Acked-by: David S. Miller <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
- Loading branch information
1 parent
69ea640
commit 1629372
Showing
5 changed files
with
48 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#ifndef _ASM_WORD_AT_A_TIME_H | ||
#define _ASM_WORD_AT_A_TIME_H | ||
|
||
/* | ||
* Word-at-a-time interfaces for PowerPC. | ||
*/ | ||
|
||
#include <linux/kernel.h> | ||
#include <asm/asm-compat.h> | ||
|
||
struct word_at_a_time { | ||
const unsigned long high_bits, low_bits; | ||
}; | ||
|
||
#define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0xfe) + 1, REPEAT_BYTE(0x7f) } | ||
|
||
/* Bit set in the bytes that have a zero */ | ||
static inline long prep_zero_mask(unsigned long val, unsigned long rhs, const struct word_at_a_time *c) | ||
{ | ||
unsigned long mask = (val & c->low_bits) + c->low_bits; | ||
return ~(mask | rhs); | ||
} | ||
|
||
#define create_zero_mask(mask) (mask) | ||
|
||
static inline long find_zero(unsigned long mask) | ||
{ | ||
long leading_zero_bits; | ||
|
||
asm (PPC_CNTLZL "%0,%1" : "=r" (leading_zero_bits) : "r" (mask)); | ||
return leading_zero_bits >> 3; | ||
} | ||
|
||
static inline bool has_zero(unsigned long val, unsigned long *data, const struct word_at_a_time *c) | ||
{ | ||
unsigned long rhs = val | c->low_bits; | ||
*data = rhs; | ||
return (val + c->high_bits) & ~rhs; | ||
} | ||
|
||
#endif /* _ASM_WORD_AT_A_TIME_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters