Part 1
요약·해설
ISO C function의 최소 subset, cbprintf() 기반 출력, 공통 heap API 기반 malloc과 POSIX 계열 errno macro 81개의 의미를 다룹니다.
ISO C · Minimal subset
printf · cbprintf
errno · 81 Macros
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
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가 없음 |
EINTR | System call이 interrupt됨 |
EIO | I/O 오류 |
ENXIO | 해당 device 또는 address가 없음 |
E2BIG | Argument 목록이 너무 긺 |
ENOEXEC | Executable format 오류 |
EBADF | 잘못된 file number |
ECHILD | Child가 없음 |
EAGAIN | 더 이상 context가 없음 |
ENOMEM | Core memory가 부족함 |
EACCES | Permission이 거부됨 |
EFAULT | 잘못된 address |
ENOTBLK | Block device가 필요함 |
EBUSY | Mount device가 사용 중임 |
EEXIST | File이 이미 존재함 |
EXDEV | Device 사이 link |
ENODEV | 해당 device가 없음 |
ENOTDIR | Directory가 아님 |
EISDIR | Directory임 |
EINVAL | 잘못된 argument |
ENFILE | File table이 넘침 |
EMFILE | 열린 file이 너무 많음 |
ENOTTY | Terminal device가 아님 |
ETXTBSY | Text file이 사용 중임 |
EFBIG | File이 너무 큼 |
ENOSPC | Device에 남은 공간이 없음 |
ESPIPE | 허용되지 않는 seek |
EROFS | 읽기 전용 file system |
EMLINK | Link가 너무 많음 |
EPIPE | 끊어진 pipe |
EDOM | Argument가 너무 큼 |
ERANGE | 결과가 너무 큼 |
ENOMSG | 예상하지 않은 message type |
EDEADLK | Resource deadlock을 회피함 |
ENOLCK | 사용할 수 있는 lock이 없음 |
ENOSTR | STREAMS device가 필요함 |
ENODATA | 예상한 message data가 없음 |
ETIME | STREAMS timeout이 발생함 |
ENOSR | Memory가 부족함 |
EPROTO | 일반 STREAMS 오류 |
EBADMSG | 잘못된 STREAMS message |
ENOSYS | Function이 구현되지 않음 |
ENOTEMPTY | Directory가 비어 있지 않음 |
ENAMETOOLONG | File 이름이 너무 긺 |
ELOOP | Symbolic link 단계가 너무 많음 |
EOPNOTSUPP | Socket에서 지원하지 않는 operation |
EPFNOSUPPORT | 지원하지 않는 protocol family |
ECONNRESET | Peer가 connection을 reset함 |
ENOBUFS | 사용할 수 있는 buffer 공간이 없음 |
EAFNOSUPPORT | 지원하지 않는 address family |
EPROTOTYPE | Socket에 맞지 않는 protocol type |
ENOTSOCK | Socket이 아닌 대상에 socket operation을 수행함 |
ENOPROTOOPT | Protocol을 사용할 수 없음 |
ESHUTDOWN | Socket shutdown 뒤에는 전송할 수 없음 |
ECONNREFUSED | Connection이 거부됨 |
EADDRINUSE | Address가 이미 사용 중임 |
ECONNABORTED | Software가 connection을 abort함 |
ENETUNREACH | Network에 도달할 수 없음 |
ENETDOWN | Network가 down 상태임 |
ETIMEDOUT | Connection 시간 초과 |
EHOSTDOWN | Host가 down 상태임 |
EHOSTUNREACH | Host로 가는 route가 없음 |
EINPROGRESS | Operation이 진행 중임 |
EALREADY | Operation이 이미 진행 중임 |
EDESTADDRREQ | Destination address가 필요함 |
EMSGSIZE | Message size 오류 |
EPROTONOSUPPORT | 지원하지 않는 protocol |
ESOCKTNOSUPPORT | 지원하지 않는 socket type |
EADDRNOTAVAIL | 요청한 address를 할당할 수 없음 |
ENETRESET | Reset 때문에 network가 connection을 끊음 |
EISCONN | Socket이 이미 연결됨 |
ENOTCONN | Socket이 연결되지 않음 |
ETOOMANYREFS | Reference가 너무 많아 splice할 수 없음 |
ENOTSUP | 지원하지 않는 값 |
EILSEQ | 잘못된 byte sequence |
EOVERFLOW | 값 overflow |
ECANCELED | Operation이 취소됨 |
EWOULDBLOCK | Operation이 block될 상황임 |
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.