aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / kernel / core / fmt.h
| 1 | /* SPDX-License-Identifier: Apache-2.0 |
| 2 | * Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* fmt.h -- freestanding printf-style formatting shared by the console and |
| 18 | * the host tests. Pure: no I/O, no globals. */ |
| 19 | #ifndef AIENOS_CK_FMT_H |
| 20 | #define AIENOS_CK_FMT_H |
| 21 | |
| 22 | #include <stdarg.h> |
| 23 | #include <stddef.h> |
| 24 | |
| 25 | typedef void (*ck_emit_fn)(void *ctx, char c); |
| 26 | |
| 27 | /* Formats into emit(); returns the number of characters produced. |
| 28 | * Supports %s %c %d %i %u %x %X %p %% with flags '-' '0', width (digits or |
| 29 | * '*') and length hh h l ll z. %p prints 0x followed by lowercase hex. */ |
| 30 | int ck_vformat(ck_emit_fn emit, void *ctx, const char *fmt, va_list ap); |
| 31 | int ck_vsnprintf(char *buf, size_t n, const char *fmt, va_list ap); |
| 32 | int ck_snprintf(char *buf, size_t n, const char *fmt, ...) __attribute__((format(printf, 3, 4))); |
| 33 | |
| 34 | #endif |