drivers/tty/vt/ucs.c
Source file repositories/reference/linux-study-clean/drivers/tty/vt/ucs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/vt/ucs.c- Extension
.c- Size
- 6316 bytes
- Lines
- 252
- Domain
- Driver Families
- Bucket
- drivers/tty
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/array_size.hlinux/bsearch.hlinux/consolemap.hlinux/minmax.hucs_width_table.hucs_recompose_table.hucs_fallback_table.h
Detected Declarations
struct ucs_interval16struct ucs_interval32struct ucs_recompositionstruct compare_keystruct ucs_page_descstruct ucs_page_entryfunction interval16_cmpfunction interval32_cmpfunction cp_in_range16function cp_in_range32function ucs_is_zero_widthfunction ucs_is_double_widthfunction recomposition_cmpfunction ucs_recomposefunction ucs_page_desc_cmpfunction ucs_page_entry_cmpfunction ucs_get_fallback
Annotated Snippet
struct ucs_interval16 {
u16 first;
u16 last;
};
struct ucs_interval32 {
u32 first;
u32 last;
};
#include "ucs_width_table.h"
static int interval16_cmp(const void *key, const void *element)
{
u16 cp = *(u16 *)key;
const struct ucs_interval16 *entry = element;
if (cp < entry->first)
return -1;
if (cp > entry->last)
return 1;
return 0;
}
static int interval32_cmp(const void *key, const void *element)
{
u32 cp = *(u32 *)key;
const struct ucs_interval32 *entry = element;
if (cp < entry->first)
return -1;
if (cp > entry->last)
return 1;
return 0;
}
static bool cp_in_range16(u16 cp, const struct ucs_interval16 *ranges, size_t size)
{
if (cp < ranges[0].first || cp > ranges[size - 1].last)
return false;
return __inline_bsearch(&cp, ranges, size, sizeof(*ranges),
interval16_cmp) != NULL;
}
static bool cp_in_range32(u32 cp, const struct ucs_interval32 *ranges, size_t size)
{
if (cp < ranges[0].first || cp > ranges[size - 1].last)
return false;
return __inline_bsearch(&cp, ranges, size, sizeof(*ranges),
interval32_cmp) != NULL;
}
#define UCS_IS_BMP(cp) ((cp) <= 0xffff)
/**
* ucs_is_zero_width() - Determine if a Unicode code point is zero-width.
* @cp: Unicode code point (UCS-4)
*
* Return: true if the character is zero-width, false otherwise
*/
bool ucs_is_zero_width(u32 cp)
{
if (UCS_IS_BMP(cp))
return cp_in_range16(cp, ucs_zero_width_bmp_ranges,
ARRAY_SIZE(ucs_zero_width_bmp_ranges));
else
return cp_in_range32(cp, ucs_zero_width_non_bmp_ranges,
ARRAY_SIZE(ucs_zero_width_non_bmp_ranges));
}
/**
* ucs_is_double_width() - Determine if a Unicode code point is double-width.
* @cp: Unicode code point (UCS-4)
*
* Return: true if the character is double-width, false otherwise
*/
bool ucs_is_double_width(u32 cp)
{
if (UCS_IS_BMP(cp))
return cp_in_range16(cp, ucs_double_width_bmp_ranges,
ARRAY_SIZE(ucs_double_width_bmp_ranges));
else
return cp_in_range32(cp, ucs_double_width_non_bmp_ranges,
ARRAY_SIZE(ucs_double_width_non_bmp_ranges));
}
/*
* Structure for base with combining mark pairs and resulting recompositions.
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/bsearch.h`, `linux/consolemap.h`, `linux/minmax.h`, `ucs_width_table.h`, `ucs_recompose_table.h`, `ucs_fallback_table.h`.
- Detected declarations: `struct ucs_interval16`, `struct ucs_interval32`, `struct ucs_recomposition`, `struct compare_key`, `struct ucs_page_desc`, `struct ucs_page_entry`, `function interval16_cmp`, `function interval32_cmp`, `function cp_in_range16`, `function cp_in_range32`.
- Atlas domain: Driver Families / drivers/tty.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.