develop/languages/c/minimal_libc.html · develop/languages/c/minimal_libc.rst 공식 원문 ↗

Zephyr 3.7.0 · Develop · Languages · C

Minimal libc

작은 footprint를 위한 Zephyr minimal libc의 구현 범위와 error code 계약을 설명합니다.

Official pathdevelop/languages/c/minimal_libc.html
Source filedevelop/languages/c/minimal_libc.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

ISO C function의 최소 subset, cbprintf() 기반 출력, 공통 heap API 기반 malloc과 POSIX 계열 errno macro 81개의 의미를 다룹니다.

범위

ISO C · Minimal subset

출력

printf · cbprintf

Error

errno · 81 Macros

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 A47C0181444E6FCAD44727233FECF906AD703937F6B9F7E12EA0EC0A98F2B058
.. _c_library_minimal:

Minimal libc
############

The most basic C library, named "minimal libc", is part of the Zephyr codebase
and provides the minimal subset of the standard C library required to meet the
needs of Zephyr and its subsystems, primarily in the areas of string
manipulation and display.

It is very low footprint and is suitable for projects that do not rely on less
frequently used portions of the ISO C standard library. It can also be used
with a number of different toolchains.

The minimal libc implementation can be found in :file:`lib/libc/minimal` in the
main Zephyr tree.

Functions
*********

The minimal libc implements the minimal subset of the ISO/IEC 9899:2011
standard C library functions required to meet the needs of the Zephyr kernel,
as defined by the :ref:`Coding Guidelines Rule A.4
<coding_guideline_libc_usage_restrictions_in_zephyr_kernel>`.

Formatted Output
****************

The minimal libc does not implement its own formatted output processor;
instead, it maps the C standard formatted output functions such as ``printf``
and ``sprintf`` to the :c:func:`cbprintf` function, which is Zephyr's own
C99-compatible formatted output implementation.

For more details, refer to the :ref:`Formatted Output <formatted_output>` OS
service documentation.

Dynamic Memory Management
*************************

The minimal libc uses the malloc api family implementation provided by the
:ref:`common C library <c_library_common>`, which itself is built upon the
:ref:`kernel memory heap API <heap_v2>`.

Error numbers
*************

Error numbers are used throughout Zephyr APIs to signal error conditions as
return values from functions. They are typically returned as the negative value
of the integer literals defined in this section, and are defined in the
:file:`errno.h` header file.

A subset of the error numbers defined in the `POSIX errno.h specification`_ and
other de-facto standard sources have been added to the minimal libc.

A conscious effort is made in Zephyr to keep the values of the minimal libc
error numbers consistent with the different implementations of the C standard
libraries supported by Zephyr. The minimal libc :file:`errno.h` is checked
against that of the :ref:`Newlib <c_library_newlib>` to ensure that the error
numbers are kept aligned.

Below is a list of the error number definitions. For the actual numeric values
please refer to `errno.h`_.

.. doxygengroup:: system_errno

.. _`POSIX errno.h specification`: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
.. _`errno.h`: https://github.com/zephyrproject-rtos/zephyr/blob/main/lib/libc/minimal/include/errno.h

Part 3

한국어 전문 번역

Minimal libc

minimal libc라는 가장 기본적인 C library는 Zephyr codebase의 일부입니다. 주로 string 조작과 표시 영역에서 Zephyr와 subsystem의 요구를 충족하는 데 필요한 C standard library의 최소 subset을 제공합니다.

Footprint가 매우 작아 ISO C standard library에서 자주 사용하지 않는 부분에 의존하지 않는 project에 적합하며 여러 toolchain과 함께 사용할 수 있습니다.

Minimal libc 구현은 main Zephyr tree의 lib/libc/minimal에 있습니다.

Function

Minimal libc는 Coding Guidelines Rule A.4가 정의한 대로 Zephyr kernel 요구를 충족하는 데 필요한 ISO/IEC 9899:2011 C standard library function의 최소 subset을 구현합니다.

Formatted output

Minimal libc는 자체 formatted output processor를 구현하지 않습니다. 대신 printf와 sprintf 같은 C standard formatted output function을 Zephyr 자체 C99-compatible formatted output 구현인 cbprintf()에 mapping합니다.

자세한 내용은 Formatted Output OS service 문서를 참고하십시오.

동적 memory 관리

Minimal libc는 공통 C library가 제공하는 malloc API family 구현을 사용하며, 이 구현은 다시 kernel memory heap API를 기반으로 합니다.

Error number

Error number는 Zephyr API 전반에서 function return value로 error condition을 알릴 때 사용합니다. 일반적으로 이 절에 정의된 integer literal의 음수 값을 return하며 errno.h header file에 정의됩니다.

POSIX errno.h specification과 사실상 standard로 쓰이는 다른 source가 정의한 error number 중 일부가 minimal libc에 추가되어 있습니다.

Zephyr는 minimal libc error number 값이 지원 C standard library의 다른 구현과 일치하도록 의도적으로 관리합니다. Minimal libc errno.h를 Newlib의 정의와 대조해 error number alignment를 유지합니다.

아래는 error number 정의 목록입니다. 실제 numeric value는 errno.h를 참고하십시오.

system_errno group은 function이 return하는 system error code와 IEEE Std 1003.1-2017이 정의한 항목을 포함합니다.

Macro의미
errno현재 thread의 error number
EPERM소유자가 아님
ENOENT해당 file 또는 directory가 없음
ESRCH해당 context가 없음
EINTRSystem call이 interrupt됨
EIOI/O 오류
ENXIO해당 device 또는 address가 없음
E2BIGArgument 목록이 너무 긺
ENOEXECExecutable format 오류
EBADF잘못된 file number
ECHILDChild가 없음
EAGAIN더 이상 context가 없음
ENOMEMCore memory가 부족함
EACCESPermission이 거부됨
EFAULT잘못된 address
ENOTBLKBlock device가 필요함
EBUSYMount device가 사용 중임
EEXISTFile이 이미 존재함
EXDEVDevice 사이 link
ENODEV해당 device가 없음
ENOTDIRDirectory가 아님
EISDIRDirectory임
EINVAL잘못된 argument
ENFILEFile table이 넘침
EMFILE열린 file이 너무 많음
ENOTTYTerminal device가 아님
ETXTBSYText file이 사용 중임
EFBIGFile이 너무 큼
ENOSPCDevice에 남은 공간이 없음
ESPIPE허용되지 않는 seek
EROFS읽기 전용 file system
EMLINKLink가 너무 많음
EPIPE끊어진 pipe
EDOMArgument가 너무 큼
ERANGE결과가 너무 큼
ENOMSG예상하지 않은 message type
EDEADLKResource deadlock을 회피함
ENOLCK사용할 수 있는 lock이 없음
ENOSTRSTREAMS device가 필요함
ENODATA예상한 message data가 없음
ETIMESTREAMS timeout이 발생함
ENOSRMemory가 부족함
EPROTO일반 STREAMS 오류
EBADMSG잘못된 STREAMS message
ENOSYSFunction이 구현되지 않음
ENOTEMPTYDirectory가 비어 있지 않음
ENAMETOOLONGFile 이름이 너무 긺
ELOOPSymbolic link 단계가 너무 많음
EOPNOTSUPPSocket에서 지원하지 않는 operation
EPFNOSUPPORT지원하지 않는 protocol family
ECONNRESETPeer가 connection을 reset함
ENOBUFS사용할 수 있는 buffer 공간이 없음
EAFNOSUPPORT지원하지 않는 address family
EPROTOTYPESocket에 맞지 않는 protocol type
ENOTSOCKSocket이 아닌 대상에 socket operation을 수행함
ENOPROTOOPTProtocol을 사용할 수 없음
ESHUTDOWNSocket shutdown 뒤에는 전송할 수 없음
ECONNREFUSEDConnection이 거부됨
EADDRINUSEAddress가 이미 사용 중임
ECONNABORTEDSoftware가 connection을 abort함
ENETUNREACHNetwork에 도달할 수 없음
ENETDOWNNetwork가 down 상태임
ETIMEDOUTConnection 시간 초과
EHOSTDOWNHost가 down 상태임
EHOSTUNREACHHost로 가는 route가 없음
EINPROGRESSOperation이 진행 중임
EALREADYOperation이 이미 진행 중임
EDESTADDRREQDestination address가 필요함
EMSGSIZEMessage size 오류
EPROTONOSUPPORT지원하지 않는 protocol
ESOCKTNOSUPPORT지원하지 않는 socket type
EADDRNOTAVAIL요청한 address를 할당할 수 없음
ENETRESETReset 때문에 network가 connection을 끊음
EISCONNSocket이 이미 연결됨
ENOTCONNSocket이 연결되지 않음
ETOOMANYREFSReference가 너무 많아 splice할 수 없음
ENOTSUP지원하지 않는 값
EILSEQ잘못된 byte sequence
EOVERFLOW값 overflow
ECANCELEDOperation이 취소됨
EWOULDBLOCKOperation이 block될 상황임

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.