aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ucs2_string.c
blob: 6f500ef2301d893c9b2c737747fc355974ff4a19 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <linux/ucs2_string.h>
#include <linux/module.h>

/* Return the number of unicode characters in data */
unsigned long
ucs2_strnlen(const ucs2_char_t *s, size_t maxlength)
{
        unsigned long length = 0;

        while (*s++ != 0 && length < maxlength)
                length++;
        return length;
}
EXPORT_SYMBOL(ucs2_strnlen);

unsigned long
ucs2_strlen(const ucs2_char_t *s)
{
        return ucs2_strnlen(s, ~0UL);
}
EXPORT_SYMBOL(ucs2_strlen);

/*
 * Return the number of bytes is the length of this string
 * Note: this is NOT the same as the number of unicode characters
 */
unsigned long
ucs2_strsize(const ucs2_char_t *data, unsigned long maxlength)
{
        return ucs2_strnlen(data, maxlength/sizeof(ucs2_char_t)) * sizeof(ucs2_char_t);
}
EXPORT_SYMBOL(ucs2_strsize);

int
ucs2_strncmp(const ucs2_char_t *a, const ucs2_char_t *b, size_t len)
{
        while (1) {
                if (len == 0)
                        return 0;
                if (*a < *b)
                        return -1;
                if (*a > *b)
                        return 1;
                if (*a == 0) /* implies *b == 0 */
                        return 0;
                a++;
                b++;
                len--;
        }
}
EXPORT_SYMBOL(ucs2_strncmp);
6f3e718465cab2aad260cf34183ce1ce&follow=1'>KVM: x86: Explicitly treat routing entry type changes as changesSean Christopherson1-1/+2 2025-04-24KVM: x86: Reset IRTE to host control if *new* route isn't postableSean Christopherson2-45/+41 2025-04-24KVM: SVM: Allocate IR data using atomic allocationSean Christopherson1-1/+1 2025-04-24KVM: SVM: Don't update IRTEs if APICv/AVIC is disabledSean Christopherson1-2/+1 2025-04-24KVM: arm64, x86: make kvm_arch_has_irq_bypass() inlinePaolo Bonzini4-10/+11 2025-04-18arm64: Rework checks for broken Cavium HW in the PI codeMarc Zyngier4-17/+25 2025-04-13Linux 6.15-rc2v6.15-rc2Linus Torvalds1-1/+1 2025-04-12ext4: fix off-by-one error in do_splitArtem Sadovnikov1-1/+1 2025-04-12ext4: make block validity check resistent to sb bh corruptionOjaswin Mujoo2-6/+6 2025-04-12ext4: avoid -Wflex-array-member-not-at-end warningGustavo A. R. Silva1-10/+8 2025-04-12Documentation: ext4: Add fields to ext4_super_block documentationTom Vierjahn1-6/+14 2025-04-12rv: Fix out-of-bound memory access in rv_is_container_monitor()Nam Cao1-1/+6 2025-04-12ftrace: Do not have print_graph_retval() add a newlineSteven Rostedt1-6/+5