mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-25 15:20:53 +07:00
b9ec0339d8
Add const modifiers to a few struct nls_table's member pointers in include/linux/nls.h and adds a lot of const's in fs/nls/*.c files. Resulting changes as visible by size: text data bss dec hex filename 113612 481216 2368 597196 91ccc nls.org/built-in.o 593548 3296 288 597132 91c8c nls/built-in.o Apparently compiler managed to optimize code a bit better because of const-ness. No other changes are made. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
65 lines
1.6 KiB
C
65 lines
1.6 KiB
C
#ifndef _LINUX_NLS_H
|
|
#define _LINUX_NLS_H
|
|
|
|
#include <linux/init.h>
|
|
|
|
/* unicode character */
|
|
typedef __u16 wchar_t;
|
|
|
|
struct nls_table {
|
|
const char *charset;
|
|
const char *alias;
|
|
int (*uni2char) (wchar_t uni, unsigned char *out, int boundlen);
|
|
int (*char2uni) (const unsigned char *rawstring, int boundlen,
|
|
wchar_t *uni);
|
|
const unsigned char *charset2lower;
|
|
const unsigned char *charset2upper;
|
|
struct module *owner;
|
|
struct nls_table *next;
|
|
};
|
|
|
|
/* this value hold the maximum octet of charset */
|
|
#define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
|
|
|
|
/* nls.c */
|
|
extern int register_nls(struct nls_table *);
|
|
extern int unregister_nls(struct nls_table *);
|
|
extern struct nls_table *load_nls(char *);
|
|
extern void unload_nls(struct nls_table *);
|
|
extern struct nls_table *load_nls_default(void);
|
|
|
|
extern int utf8_mbtowc(wchar_t *, const __u8 *, int);
|
|
extern int utf8_mbstowcs(wchar_t *, const __u8 *, int);
|
|
extern int utf8_wctomb(__u8 *, wchar_t, int);
|
|
extern int utf8_wcstombs(__u8 *, const wchar_t *, int);
|
|
|
|
static inline unsigned char nls_tolower(struct nls_table *t, unsigned char c)
|
|
{
|
|
unsigned char nc = t->charset2lower[c];
|
|
|
|
return nc ? nc : c;
|
|
}
|
|
|
|
static inline unsigned char nls_toupper(struct nls_table *t, unsigned char c)
|
|
{
|
|
unsigned char nc = t->charset2upper[c];
|
|
|
|
return nc ? nc : c;
|
|
}
|
|
|
|
static inline int nls_strnicmp(struct nls_table *t, const unsigned char *s1,
|
|
const unsigned char *s2, int len)
|
|
{
|
|
while (len--) {
|
|
if (nls_tolower(t, *s1++) != nls_tolower(t, *s2++))
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
#define MODULE_ALIAS_NLS(name) MODULE_ALIAS("nls_" __stringify(name))
|
|
|
|
#endif /* _LINUX_NLS_H */
|
|
|