Merge tag 'v4.5-rc6' into locking/core, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
@@ -282,9 +282,9 @@ void klist_iter_init_node(struct klist *k, struct klist_iter *i,
|
||||
struct klist_node *n)
|
||||
{
|
||||
i->i_klist = k;
|
||||
i->i_cur = n;
|
||||
if (n)
|
||||
kref_get(&n->n_ref);
|
||||
i->i_cur = NULL;
|
||||
if (n && kref_get_unless_zero(&n->n_ref))
|
||||
i->i_cur = n;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(klist_iter_init_node);
|
||||
|
||||
|
@@ -49,3 +49,65 @@ ucs2_strncmp(const ucs2_char_t *a, const ucs2_char_t *b, size_t len)
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(ucs2_strncmp);
|
||||
|
||||
unsigned long
|
||||
ucs2_utf8size(const ucs2_char_t *src)
|
||||
{
|
||||
unsigned long i;
|
||||
unsigned long j = 0;
|
||||
|
||||
for (i = 0; i < ucs2_strlen(src); i++) {
|
||||
u16 c = src[i];
|
||||
|
||||
if (c >= 0x800)
|
||||
j += 3;
|
||||
else if (c >= 0x80)
|
||||
j += 2;
|
||||
else
|
||||
j += 1;
|
||||
}
|
||||
|
||||
return j;
|
||||
}
|
||||
EXPORT_SYMBOL(ucs2_utf8size);
|
||||
|
||||
/*
|
||||
* copy at most maxlength bytes of whole utf8 characters to dest from the
|
||||
* ucs2 string src.
|
||||
*
|
||||
* The return value is the number of characters copied, not including the
|
||||
* final NUL character.
|
||||
*/
|
||||
unsigned long
|
||||
ucs2_as_utf8(u8 *dest, const ucs2_char_t *src, unsigned long maxlength)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned long j = 0;
|
||||
unsigned long limit = ucs2_strnlen(src, maxlength);
|
||||
|
||||
for (i = 0; maxlength && i < limit; i++) {
|
||||
u16 c = src[i];
|
||||
|
||||
if (c >= 0x800) {
|
||||
if (maxlength < 3)
|
||||
break;
|
||||
maxlength -= 3;
|
||||
dest[j++] = 0xe0 | (c & 0xf000) >> 12;
|
||||
dest[j++] = 0x80 | (c & 0x0fc0) >> 6;
|
||||
dest[j++] = 0x80 | (c & 0x003f);
|
||||
} else if (c >= 0x80) {
|
||||
if (maxlength < 2)
|
||||
break;
|
||||
maxlength -= 2;
|
||||
dest[j++] = 0xc0 | (c & 0x7c0) >> 6;
|
||||
dest[j++] = 0x80 | (c & 0x03f);
|
||||
} else {
|
||||
maxlength -= 1;
|
||||
dest[j++] = c & 0x7f;
|
||||
}
|
||||
}
|
||||
if (maxlength)
|
||||
dest[j] = '\0';
|
||||
return j;
|
||||
}
|
||||
EXPORT_SYMBOL(ucs2_as_utf8);
|
||||
|
Reference in New Issue
Block a user