Replace use of base/snprintf.h by format library

Issue #2064
This commit is contained in:
Norman Feske 2023-03-06 14:58:06 +01:00 committed by Christian Helmuth
parent 9ef0f1b6cb
commit e9b249b709
54 changed files with 139 additions and 80 deletions

View File

@ -1,4 +1,5 @@
base base
file_system_session file_system_session
libgcov libgcov
format
os os

View File

@ -1,5 +1,6 @@
base base
os os
format
audio_in_session audio_in_session
audio_out_session audio_out_session
platform_session platform_session

View File

@ -1,7 +1,7 @@
REQUIRES = x86 REQUIRES = x86
TARGET = pci_audio_drv TARGET = pci_audio_drv
SRC_CC = main.cc SRC_CC = main.cc
LIBS = dde_bsd_audio base LIBS = dde_bsd_audio base format
INC_DIR += $(REP_DIR)/include INC_DIR += $(REP_DIR)/include
vpath %.cc $(REP_DIR)/src/drivers/audio vpath %.cc $(REP_DIR)/src/drivers/audio

View File

@ -19,6 +19,9 @@
#include <os/reporter.h> #include <os/reporter.h>
#include <util/xml_node.h> #include <util/xml_node.h>
/* format-string includes */
#include <format/snprintf.h>
/* local includes */ /* local includes */
#include <audio/audio.h> #include <audio/audio.h>
#include <bsd.h> #include <bsd.h>
@ -143,7 +146,7 @@ static bool set_mixer_value(Mixer &mixer, char const * const field,
char const * const class_name = mixer.info[mixer_class].label.name; char const * const class_name = mixer.info[mixer_class].label.name;
char const * const name = info.label.name; char const * const name = info.label.name;
Genode::snprintf(buffer, sizeof(buffer), "%s.%s", class_name, name); Format::snprintf(buffer, sizeof(buffer), "%s.%s", class_name, name);
if (Genode::strcmp(field, buffer) != 0) if (Genode::strcmp(field, buffer) != 0)
continue; continue;
@ -238,7 +241,7 @@ static char const *get_mixer_value(mixer_devinfo_t const *info)
{ {
for (int i = 0; i < info->un.e.num_mem; i++) for (int i = 0; i < info->un.e.num_mem; i++)
if (ctrl.un.ord == info->un.e.member[i].ord) { if (ctrl.un.ord == info->un.e.member[i].ord) {
Genode::snprintf(buffer, sizeof(buffer), Format::snprintf(buffer, sizeof(buffer),
"%s", info->un.e.member[i].label.name); "%s", info->un.e.member[i].label.name);
break; break;
} }
@ -250,7 +253,7 @@ static char const *get_mixer_value(mixer_devinfo_t const *info)
Genode::size_t n = 0; Genode::size_t n = 0;
for (int i = 0; i < info->un.s.num_mem; i++) for (int i = 0; i < info->un.s.num_mem; i++)
if (ctrl.un.mask & info->un.s.member[i].mask) if (ctrl.un.mask & info->un.s.member[i].mask)
n += Genode::snprintf(p + n, sizeof(buffer) - n, n += Format::snprintf(p + n, sizeof(buffer) - n,
"%s%s", n ? "," : "", "%s%s", n ? "," : "",
info->un.s.member[i].label.name); info->un.s.member[i].label.name);
break; break;
@ -258,11 +261,11 @@ static char const *get_mixer_value(mixer_devinfo_t const *info)
case AUDIO_MIXER_VALUE: case AUDIO_MIXER_VALUE:
{ {
if (ctrl.un.value.num_channels == 2) if (ctrl.un.value.num_channels == 2)
Genode::snprintf(buffer, sizeof(buffer), "%d,%d", Format::snprintf(buffer, sizeof(buffer), "%d,%d",
ctrl.un.value.level[0], ctrl.un.value.level[0],
ctrl.un.value.level[1]); ctrl.un.value.level[1]);
else else
Genode::snprintf(buffer, sizeof(buffer), "%d", Format::snprintf(buffer, sizeof(buffer), "%d",
ctrl.un.value.level[0]); ctrl.un.value.level[0]);
break; break;
} }
@ -374,7 +377,7 @@ static void configure_mixer(Genode::Env &env, Mixer &mixer, Genode::Xml_node con
if (value) { if (value) {
xml.node("mixer", [&]() { xml.node("mixer", [&]() {
char tmp[64]; char tmp[64];
Genode::snprintf(tmp, sizeof(tmp), "%s.%s", Format::snprintf(tmp, sizeof(tmp), "%s.%s",
class_name, name); class_name, name);
xml.attribute("field", tmp); xml.attribute("field", tmp);

View File

@ -15,9 +15,11 @@
/* Genode includes */ /* Genode includes */
#include <base/log.h> #include <base/log.h>
#include <base/sleep.h> #include <base/sleep.h>
#include <base/snprintf.h>
#include <util/string.h> #include <util/string.h>
/* format-string includes */
#include <format/snprintf.h>
/* local includes */ /* local includes */
#include <bsd_emul.h> #include <bsd_emul.h>
@ -440,7 +442,7 @@ extern "C" int snprintf(char *str, size_t size, const char *format, ...)
va_list list; va_list list;
va_start(list, format); va_start(list, format);
Genode::String_console sc(str, size); Format::String_console sc(str, size);
sc.vprintf(format, list); sc.vprintf(format, list);
va_end(list); va_end(list);

View File

@ -2,6 +2,7 @@ base
nic_driver nic_driver
nic_session nic_session
os os
format
platform_session platform_session
report_session report_session
timer_session timer_session

View File

@ -1,6 +1,6 @@
TARGET = ipxe_nic_drv TARGET = ipxe_nic_drv
REQUIRES = x86 REQUIRES = x86
LIBS = base dde_ipxe_nic nic_driver LIBS = base dde_ipxe_nic nic_driver format
SRC_CC = main.cc SRC_CC = main.cc
CC_CXX_WARN_STRICT = CC_CXX_WARN_STRICT =

View File

@ -39,6 +39,9 @@
#include <util/retry.h> #include <util/retry.h>
#include <util/reconstructible.h> #include <util/reconstructible.h>
/* format-string includes */
#include <format/snprintf.h>
/* local includes */ /* local includes */
#include <dde_support.h> #include <dde_support.h>
@ -77,7 +80,7 @@ extern "C" void dde_vprintf(const char *format, va_list list)
using namespace Genode; using namespace Genode;
char buf[128] { }; char buf[128] { };
String_console(buf, sizeof(buf)).vprintf(format, list); Format::String_console(buf, sizeof(buf)).vprintf(format, list);
log(Cstring(buf)); log(Cstring(buf));
} }

View File

@ -3,7 +3,7 @@ SHARED_LIB = yes
LIB_DIR = $(REP_DIR)/src/lib/lxip LIB_DIR = $(REP_DIR)/src/lib/lxip
LIB_INC_DIR = $(LIB_DIR)/include LIB_INC_DIR = $(LIB_DIR)/include
LIBS += lxip_include LIBS += lxip_include format
LX_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/lib/lxip LX_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/lib/lxip
NET_DIR := $(LX_CONTRIB_DIR)/net NET_DIR := $(LX_CONTRIB_DIR)/net

View File

@ -1,5 +1,6 @@
base base
os os
format
usb_session usb_session
gpio_session gpio_session
platform_session platform_session

View File

@ -1,5 +1,6 @@
base base
os os
format
event_session event_session
report_session report_session
usb_session usb_session

View File

@ -1,5 +1,6 @@
base base
os os
format
nic_session nic_session
uplink_session uplink_session
usb_session usb_session

View File

@ -1,5 +1,6 @@
base base
os os
format
nic_session nic_session
uplink_session uplink_session
usb_session usb_session

View File

@ -4,3 +4,4 @@ os
so so
timer_session timer_session
vfs vfs
format

View File

@ -3,7 +3,7 @@ SRC_C := dummies.c
SRC_CC := main.cc lx_emul.cc evdev.cc SRC_CC := main.cc lx_emul.cc evdev.cc
SRC_CC += printf.cc bug.cc timer.cc scheduler.cc env.cc work.cc SRC_CC += printf.cc bug.cc timer.cc scheduler.cc env.cc work.cc
LIBS := base usb_hid_include lx_kit_setjmp LIBS := base usb_hid_include lx_kit_setjmp format
USB_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/drivers/usb_hid USB_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/drivers/usb_hid

View File

@ -20,6 +20,9 @@
#include <util/bit_allocator.h> #include <util/bit_allocator.h>
#include <util/string.h> #include <util/string.h>
/* format-string includes */
#include <format/snprintf.h>
/* Local includes */ /* Local includes */
#include "signal.h" #include "signal.h"
#include "lx_emul.h" #include "lx_emul.h"
@ -120,7 +123,7 @@ bool access_ok(int access, void *addr, size_t size) { return 1; }
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
{ {
Genode::String_console sc(buf, size); Format::String_console sc(buf, size);
sc.vprintf(fmt, args); sc.vprintf(fmt, args);
return sc.len(); return sc.len();
@ -132,7 +135,7 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
Genode::String_console sc(buf, size); Format::String_console sc(buf, size);
sc.vprintf(fmt, args); sc.vprintf(fmt, args);
va_end(args); va_end(args);
@ -145,7 +148,7 @@ int scnprintf(char *buf, size_t size, const char *fmt, ...)
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
Genode::String_console sc(buf, size); Format::String_console sc(buf, size);
sc.vprintf(fmt, args); sc.vprintf(fmt, args);
va_end(args); va_end(args);

View File

@ -1,7 +1,7 @@
LX_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/drivers/usb_host LX_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/drivers/usb_host
SRC_CC = main.cc lx_emul.cc raw.cc SRC_CC = main.cc lx_emul.cc raw.cc
SRC_C = dummies.c raw_driver.c SRC_C = dummies.c raw_driver.c
LIBS = base usb_host_include lx_kit_setjmp LIBS = base usb_host_include lx_kit_setjmp format
CC_CXX_WARN_STRICT = CC_CXX_WARN_STRICT =
INC_DIR += $(PRG_DIR) INC_DIR += $(PRG_DIR)

View File

@ -14,7 +14,7 @@
#include <base/env.h> #include <base/env.h>
#include <usb_session/client.h> #include <usb_session/client.h>
#include <base/snprintf.h> #include <format/snprintf.h>
#include <nic_session/nic_session.h> #include <nic_session/nic_session.h>
#include <util/xml_node.h> #include <util/xml_node.h>
@ -345,7 +345,7 @@ enum { MAC_LEN = 17 };
static void snprint_mac(char *buf, u8 *mac) static void snprint_mac(char *buf, u8 *mac)
{ {
for (int i = 0; i < ETH_ALEN; i++) { for (int i = 0; i < ETH_ALEN; i++) {
Genode::snprintf((char *)&buf[i * 3], 3, "%02x", mac[i]); Format::snprintf((char *)&buf[i * 3], 3, "%02x", mac[i]);
if ((i * 3) < MAC_LEN) if ((i * 3) < MAC_LEN)
buf[(i * 3) + 2] = ':'; buf[(i * 3) + 2] = ':';
} }

View File

@ -4,7 +4,7 @@ SRC_CC := main.cc lx_emul.cc terminal.cc fec_nic.cc
SRC_CC += printf.cc bug.cc timer.cc scheduler.cc malloc.cc env.cc work.cc SRC_CC += printf.cc bug.cc timer.cc scheduler.cc malloc.cc env.cc work.cc
SRC_CC += uplink_client.cc SRC_CC += uplink_client.cc
LIBS := base usb_modem_include lx_kit_setjmp nic_driver LIBS := base usb_modem_include lx_kit_setjmp nic_driver format
USB_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/drivers/usb_modem USB_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/drivers/usb_modem

View File

@ -1,6 +1,6 @@
#include <base/env.h> #include <base/env.h>
#include <usb_session/client.h> #include <usb_session/client.h>
#include <base/snprintf.h> #include <format/snprintf.h>
#include <nic_session/nic_session.h> #include <nic_session/nic_session.h>
#include <util/xml_node.h> #include <util/xml_node.h>
@ -324,7 +324,7 @@ enum { MAC_LEN = 17 };
static void snprint_mac(char *buf, u8 *mac) static void snprint_mac(char *buf, u8 *mac)
{ {
for (int i = 0; i < ETH_ALEN; i++) { for (int i = 0; i < ETH_ALEN; i++) {
Genode::snprintf((char *)&buf[i * 3], 3, "%02x", mac[i]); Format::snprintf((char *)&buf[i * 3], 3, "%02x", mac[i]);
if ((i * 3) < MAC_LEN) if ((i * 3) < MAC_LEN)
buf[(i * 3) + 2] = ':'; buf[(i * 3) + 2] = ':';
} }

View File

@ -4,7 +4,7 @@ SRC_CC := main.cc lx_emul.cc linux_network_session_base.cc
SRC_CC += printf.cc bug.cc timer.cc scheduler.cc malloc.cc env.cc work.cc SRC_CC += printf.cc bug.cc timer.cc scheduler.cc malloc.cc env.cc work.cc
SRC_CC += uplink_client.cc SRC_CC += uplink_client.cc
LIBS := base usb_net_include lx_kit_setjmp nic_driver LIBS := base usb_net_include lx_kit_setjmp nic_driver format
USB_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/drivers/usb_net USB_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/drivers/usb_net

View File

@ -12,7 +12,7 @@
*/ */
/* Genode includes */ /* Genode includes */
#include <base/snprintf.h> #include <format/snprintf.h>
int sprintf(char *str, const char *format, ...) int sprintf(char *str, const char *format, ...)
@ -21,7 +21,7 @@ int sprintf(char *str, const char *format, ...)
va_list list; va_list list;
va_start(list, format); va_start(list, format);
Genode::String_console sc(str, BUFFER_LEN); Format::String_console sc(str, BUFFER_LEN);
sc.vprintf(format, list); sc.vprintf(format, list);
va_end(list); va_end(list);
@ -34,7 +34,7 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
Genode::String_console sc(buf, size); Format::String_console sc(buf, size);
sc.vprintf(fmt, args); sc.vprintf(fmt, args);
va_end(args); va_end(args);

View File

@ -15,10 +15,12 @@
/* Genode includes */ /* Genode includes */
#include <base/entrypoint.h> #include <base/entrypoint.h>
#include <base/snprintf.h>
#include <base/tslab.h> #include <base/tslab.h>
#include <irq_session/client.h> #include <irq_session/client.h>
/* format-string includes */
#include <format/snprintf.h>
/* Linux emulation environment */ /* Linux emulation environment */
#include <lx_emul.h> #include <lx_emul.h>
@ -43,7 +45,7 @@ class Lx_kit::Irq : public Lx::Irq
Name_composer(unsigned number) Name_composer(unsigned number)
{ {
Genode::snprintf(name, sizeof(name), Format::snprintf(name, sizeof(name),
"irq_%02x", number); "irq_%02x", number);
} }
}; };

View File

@ -14,11 +14,13 @@
/* Genode includes */ /* Genode includes */
#include <base/env.h> #include <base/env.h>
#include <base/log.h> #include <base/log.h>
#include <base/snprintf.h>
#include <util/list.h> #include <util/list.h>
#include <util/string.h> #include <util/string.h>
#include <util/misc_math.h> #include <util/misc_math.h>
/* compiler includes */
#include <stdarg.h>
/* Libc includes */ /* Libc includes */
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>

View File

@ -17,17 +17,18 @@
#include <base/allocator_avl.h> #include <base/allocator_avl.h>
#include <base/object_pool.h> #include <base/object_pool.h>
#include <base/sleep.h> #include <base/sleep.h>
#include <base/snprintf.h>
#include <dataspace/client.h> #include <dataspace/client.h>
#include <region_map/client.h> #include <region_map/client.h>
#include <trace/timestamp.h> #include <trace/timestamp.h>
#include <timer_session/connection.h> #include <timer_session/connection.h>
/* format-string includes */
#include <format/snprintf.h>
/* local includes */ /* local includes */
#include <lx_emul.h> #include <lx_emul.h>
#include <lx.h> #include <lx.h>
/* Lx_kit */ /* Lx_kit */
#include <legacy/lx_kit/env.h> #include <legacy/lx_kit/env.h>
@ -271,7 +272,7 @@ int snprintf(char *str, size_t size, const char *format, ...)
va_list list; va_list list;
va_start(list, format); va_start(list, format);
Genode::String_console sc(str, size); Format::String_console sc(str, size);
sc.vprintf(format, list); sc.vprintf(format, list);
va_end(list); va_end(list);
@ -457,13 +458,13 @@ static void create_event(char const *fmt, va_list list)
using namespace Genode; using namespace Genode;
String_console sc(buf, BUFFER_LEN); Format::String_console sc(buf, BUFFER_LEN);
sc.vprintf(fmt, list); sc.vprintf(fmt, list);
char event[EVENT_LEN]; char event[EVENT_LEN];
static Trace::Timestamp last = 0; static Trace::Timestamp last = 0;
Trace::Timestamp now = Trace::timestamp(); Trace::Timestamp now = Trace::timestamp();
Genode::snprintf(event, sizeof(event), "delta = %llu ms %s", Format::snprintf(event, sizeof(event), "delta = %llu ms %s",
(now - last) / 2260000, buf); (now - last) / 2260000, buf);
Thread::trace(event); Thread::trace(event);
last = now; last = now;

View File

@ -18,6 +18,9 @@
#include <nic/packet_allocator.h> #include <nic/packet_allocator.h>
#include <nic_session/connection.h> #include <nic_session/connection.h>
/* format-string includes */
#include <format/snprintf.h>
/* local includes */ /* local includes */
#include <lx.h> #include <lx.h>
#include <nic.h> #include <nic.h>
@ -162,7 +165,7 @@ void net_mac(void* mac, unsigned long size)
unsigned char const *mac_addr = (unsigned char const*)m.addr; unsigned char const *mac_addr = (unsigned char const*)m.addr;
for (int i = 0; i < ETH_ALEN; i++) { for (int i = 0; i < ETH_ALEN; i++) {
Genode::snprintf((char *)&str[i * 3], 3, "%02x", mac_addr[i]); Format::snprintf((char *)&str[i * 3], 3, "%02x", mac_addr[i]);
if ((i * 3) < MAC_LEN) if ((i * 3) < MAC_LEN)
str[(i * 3) + 2] = ':'; str[(i * 3) + 2] = ':';
} }

View File

@ -15,7 +15,6 @@
/* Genode includes */ /* Genode includes */
#include <base/log.h> #include <base/log.h>
#include <base/snprintf.h>
#include <net/ipv4.h> #include <net/ipv4.h>
#include <util/string.h> #include <util/string.h>
#include <util/xml_node.h> #include <util/xml_node.h>
@ -25,6 +24,9 @@
#include <vfs/vfs_handle.h> #include <vfs/vfs_handle.h>
#include <timer_session/connection.h> #include <timer_session/connection.h>
/* format-string includes */
#include <format/snprintf.h>
/* Lxip includes */ /* Lxip includes */
#include <lxip/lxip.h> #include <lxip/lxip.h>
#include <lx.h> #include <lx.h>
@ -656,7 +658,7 @@ class Vfs::Lxip_listen_file final : public Vfs::Lxip_file
Byte_range_ptr const &dst, Byte_range_ptr const &dst,
file_size /* ignored */) override file_size /* ignored */) override
{ {
return Genode::snprintf(dst.start, dst.num_bytes, "%lu\n", _backlog); return Format::snprintf(dst.start, dst.num_bytes, "%lu\n", _backlog);
} }
}; };
@ -764,11 +766,11 @@ class Vfs::Lxip_connect_file final : public Vfs::Lxip_file
switch (so_error) { switch (so_error) {
case 0: case 0:
return Genode::snprintf(dst.start, dst.num_bytes, "connected"); return Format::snprintf(dst.start, dst.num_bytes, "connected");
case Linux::ECONNREFUSED: case Linux::ECONNREFUSED:
return Genode::snprintf(dst.start, dst.num_bytes, "connection refused"); return Format::snprintf(dst.start, dst.num_bytes, "connection refused");
default: default:
return Genode::snprintf(dst.start, dst.num_bytes, "unknown error"); return Format::snprintf(dst.start, dst.num_bytes, "unknown error");
} }
} }
}; };
@ -806,7 +808,7 @@ class Vfs::Lxip_local_file final : public Vfs::Lxip_file
in_addr const i_addr = addr->sin_addr; in_addr const i_addr = addr->sin_addr;
unsigned char const *a = (unsigned char *)&i_addr.s_addr; unsigned char const *a = (unsigned char *)&i_addr.s_addr;
unsigned char const *p = (unsigned char *)&addr->sin_port; unsigned char const *p = (unsigned char *)&addr->sin_port;
return Genode::snprintf(dst.start, dst.num_bytes, return Format::snprintf(dst.start, dst.num_bytes,
"%d.%d.%d.%d:%u\n", "%d.%d.%d.%d:%u\n",
a[0], a[1], a[2], a[3], (p[0]<<8)|(p[1]<<0)); a[0], a[1], a[2], a[3], (p[0]<<8)|(p[1]<<0));
} }
@ -883,7 +885,7 @@ class Vfs::Lxip_remote_file final : public Vfs::Lxip_file
in_addr const i_addr = addr->sin_addr; in_addr const i_addr = addr->sin_addr;
unsigned char const *a = (unsigned char *)&i_addr.s_addr; unsigned char const *a = (unsigned char *)&i_addr.s_addr;
unsigned char const *p = (unsigned char *)&addr->sin_port; unsigned char const *p = (unsigned char *)&addr->sin_port;
return Genode::snprintf(dst.start, dst.num_bytes, return Format::snprintf(dst.start, dst.num_bytes,
"%d.%d.%d.%d:%u\n", "%d.%d.%d.%d:%u\n",
a[0], a[1], a[2], a[3], (p[0]<<8)|(p[1]<<0)); a[0], a[1], a[2], a[3], (p[0]<<8)|(p[1]<<0));
} }
@ -1014,7 +1016,7 @@ class Vfs::Lxip_socket_dir final : public Lxip::Socket_dir
_alloc(alloc), _parent(parent), _alloc(alloc), _parent(parent),
_sock(sock), id(parent.adopt_socket(*this)) _sock(sock), id(parent.adopt_socket(*this))
{ {
Genode::snprintf(_name, sizeof(_name), "%u", id); Format::snprintf(_name, sizeof(_name), "%u", id);
for (Vfs::File * &file : _files) file = nullptr; for (Vfs::File * &file : _files) file = nullptr;
@ -1177,7 +1179,7 @@ struct Vfs::Lxip_socket_handle final : Vfs::Lxip_vfs_handle
Read_result read(Byte_range_ptr const &dst, size_t &out_count) override Read_result read(Byte_range_ptr const &dst, size_t &out_count) override
{ {
out_count = Genode::snprintf( out_count = Format::snprintf(
dst.start, dst.num_bytes, "%s/%s\n", socket_dir.parent().name(), socket_dir.name()); dst.start, dst.num_bytes, "%s/%s\n", socket_dir.parent().name(), socket_dir.name());
return Read_result::READ_OK; return Read_result::READ_OK;
} }

View File

@ -1,5 +1,5 @@
SRC_CC = vfs_rump.cc random.cc SRC_CC = vfs_rump.cc random.cc
LIBS = rump rump_fs LIBS = rump rump_fs format
INC_DIR += $(REP_DIR)/src/lib/vfs/rump INC_DIR += $(REP_DIR)/src/lib/vfs/rump
INC_DIR += $(REP_DIR)/src/include INC_DIR += $(REP_DIR)/src/include
vpath %.cc $(REP_DIR)/src/lib/vfs/rump vpath %.cc $(REP_DIR)/src/lib/vfs/rump

View File

@ -5,3 +5,4 @@ file_system
file_system_session file_system_session
timer_session timer_session
vfs vfs
format

View File

@ -21,6 +21,7 @@
#include <util/allocator_fap.h> #include <util/allocator_fap.h>
#include <util/random.h> #include <util/random.h>
#include <util/string.h> #include <util/string.h>
#include <format/snprintf.h>
enum { enum {
SUPPORTED_RUMP_VERSION = 17, SUPPORTED_RUMP_VERSION = 17,
@ -193,7 +194,7 @@ int rumpuser_getparam(const char *name, void *buf, size_t buflen)
rump_ram = Genode::min((unsigned long)MAX_VIRTUAL_MEMORY, rump_ram); rump_ram = Genode::min((unsigned long)MAX_VIRTUAL_MEMORY, rump_ram);
/* convert to string */ /* convert to string */
Genode::snprintf((char *)buf, buflen, "%zu", rump_ram); Format::snprintf((char *)buf, buflen, "%zu", rump_ram);
return 0; return 0;
} }

View File

@ -17,6 +17,7 @@
#include <block_session/connection.h> #include <block_session/connection.h>
#include <rump/env.h> #include <rump/env.h>
#include <rump_fs/fs.h> #include <rump_fs/fs.h>
#include <format/snprintf.h>
static const bool verbose = false; static const bool verbose = false;
@ -361,7 +362,7 @@ void rumpuser_dprintf(const char *format, ...)
va_start(list, format); va_start(list, format);
char buf[128] { }; char buf[128] { };
Genode::String_console(buf, sizeof(buf)).vprintf(format, list); Format::String_console(buf, sizeof(buf)).vprintf(format, list);
Genode::log(Genode::Cstring(buf)); Genode::log(Genode::Cstring(buf));
va_end(list); va_end(list);

View File

@ -2,6 +2,8 @@ SRC_CC = snprintf.cc vsnprintf.cc atol.cc strtol.cc strtod.cc \
malloc_free.cc memcmp.cc strlen.cc memset.cc abort.cc \ malloc_free.cc memcmp.cc strlen.cc memset.cc abort.cc \
mini_c.cc mini_c.cc
LIBS += format
STDINC = yes STDINC = yes
vpath % $(REP_DIR)/src/lib/mini_c vpath % $(REP_DIR)/src/lib/mini_c

View File

@ -1,6 +1,7 @@
base base
os os
blit blit
format
nitpicker_gfx nitpicker_gfx
timer_session timer_session
input_session input_session

View File

@ -11,15 +11,15 @@
* under the terms of the GNU Affero General Public License version 3. * under the terms of the GNU Affero General Public License version 3.
*/ */
#include <base/snprintf.h> #include <format/snprintf.h>
#include <stdio.h> #include <stdio.h>
extern "C" int snprintf(char *dst, Genode::size_t dst_len, const char *format, ...) extern "C" int snprintf(char *dst, Format::size_t dst_len, const char *format, ...)
{ {
va_list list; va_list list;
va_start(list, format); va_start(list, format);
Genode::String_console sc(dst, dst_len); Format::String_console sc(dst, dst_len);
sc.vprintf(format, list); sc.vprintf(format, list);
va_end(list); va_end(list);

View File

@ -11,11 +11,11 @@
* under the terms of the GNU Affero General Public License version 3. * under the terms of the GNU Affero General Public License version 3.
*/ */
#include <base/snprintf.h> #include <format/snprintf.h>
extern "C" int vsnprintf(char *dst, Genode::size_t dst_len, const char *format, va_list list) extern "C" int vsnprintf(char *dst, Format::size_t dst_len, const char *format, va_list list)
{ {
Genode::String_console sc(dst, dst_len); Format::String_console sc(dst, dst_len);
sc.vprintf(format, list); sc.vprintf(format, list);
return (int)sc.len(); return (int)sc.len();
} }

View File

@ -26,7 +26,7 @@ CC_OPT_version += -DBASEVER="\"10.3.0\"" \
-DPKGVERSION="\"(GCC) \"" \ -DPKGVERSION="\"(GCC) \"" \
-DBUGURL="\"<http://gcc.gnu.org/bugs.html>\"" -DBUGURL="\"<http://gcc.gnu.org/bugs.html>\""
LIBS += libc gmp stdcxx LIBS += libc gmp stdcxx format
INC_DIR += $(GCOV_DIR)/include \ INC_DIR += $(GCOV_DIR)/include \
$(GCOV_DIR)/libcpp/include $(GCOV_DIR)/libcpp/include

View File

@ -70,3 +70,5 @@ vpath %.c $(GCOV_DIR)/libgcc
vpath libc.cc $(REP_DIR)/src/lib/gcov/libc vpath libc.cc $(REP_DIR)/src/lib/gcov/libc
CC_CXX_WARN_STRICT = CC_CXX_WARN_STRICT =
LIBS += format

View File

@ -8,6 +8,7 @@ INC_DIR += $(LIB_DIR) $(QEMU_USB_DIR)
LIBS = qemu-usb_include LIBS = qemu-usb_include
LIBS += libc LIBS += libc
LIBS += libyuv LIBS += libyuv
LIBS += format
SRC_CC = dummies.cc qemu_emul.cc host.cc webcam.cc SRC_CC = dummies.cc qemu_emul.cc host.cc webcam.cc

View File

@ -7,7 +7,7 @@ REP_INC_DIR += src/lib/lwip/include
LD_OPT += --version-script=$(VFS_DIR)/symbol.map LD_OPT += --version-script=$(VFS_DIR)/symbol.map
LIBS += lwip LIBS += lwip format
vpath %.cc $(VFS_DIR) vpath %.cc $(VFS_DIR)

View File

@ -4,3 +4,4 @@ libc
posix posix
stdcxx stdcxx
zlib zlib
format

View File

@ -1,3 +1,4 @@
base base
libc libc
so so
format

View File

@ -1,6 +1,7 @@
base base
os os
blit blit
format
platform_session platform_session
timer_session timer_session
capture_session capture_session

View File

@ -5,3 +5,4 @@ os
so so
timer_session timer_session
vfs vfs
format

View File

@ -22,6 +22,9 @@
#include <util/reconstructible.h> #include <util/reconstructible.h>
#include <io_port_session/connection.h> #include <io_port_session/connection.h>
/* format-string includes */
#include <format/snprintf.h>
/* local includes */ /* local includes */
#include "ifx86emu.h" #include "ifx86emu.h"
#include "framebuffer.h" #include "framebuffer.h"
@ -502,7 +505,7 @@ void X86emu::printk(const char *format, ...)
va_start(list, format); va_start(list, format);
char buf[128]; char buf[128];
String_console sc(buf, sizeof(buf)); Format::String_console sc(buf, sizeof(buf));
sc.vprintf(format, list); sc.vprintf(format, list);
va_end(list); va_end(list);

View File

@ -1,7 +1,7 @@
TARGET = vesa_fb_drv TARGET = vesa_fb_drv
REQUIRES = x86 REQUIRES = x86
SRC_CC = main.cc framebuffer.cc ifx86emu.cc hw_emul.cc SRC_CC = main.cc framebuffer.cc ifx86emu.cc hw_emul.cc
LIBS = base blit x86emu LIBS = base blit x86emu format
INC_DIR += $(PRG_DIR)/include $(REP_DIR)/include/x86emu INC_DIR += $(PRG_DIR)/include $(REP_DIR)/include/x86emu
CC_CXX_WARN_STRICT = CC_CXX_WARN_STRICT =

View File

@ -21,6 +21,7 @@
#include <file_system/util.h> #include <file_system/util.h>
#include <util/string.h> #include <util/string.h>
#include <util/xml_node.h> #include <util/xml_node.h>
#include <format/snprintf.h>
extern "C" { extern "C" {
#include "stdio.h" #include "stdio.h"
@ -394,7 +395,7 @@ extern "C" void *malloc(size_t size)
extern "C" int sprintf(char *str, const char *format, ...) extern "C" int sprintf(char *str, const char *format, ...)
{ {
using namespace Genode; using namespace Format;
va_list list; va_list list;
va_start(list, format); va_start(list, format);
@ -458,7 +459,7 @@ extern "C" int vfprintf(FILE *stream, const char *format, va_list list)
if (stream != stderr) if (stream != stderr)
return 0; return 0;
using namespace Genode; using namespace Format;
char buf[1024] { }; char buf[1024] { };
String_console sc { buf, sizeof(buf) }; String_console sc { buf, sizeof(buf) };

View File

@ -18,6 +18,9 @@
#include <base/log.h> #include <base/log.h>
#include <util/misc_math.h> #include <util/misc_math.h>
/* format-string includes */
#include <format/snprintf.h>
/* local includes */ /* local includes */
#include <extern_c_begin.h> #include <extern_c_begin.h>
#include <qemu_emul.h> #include <qemu_emul.h>
@ -157,7 +160,7 @@ void qemu_printf(char const *fmt, ...)
char buf[BUF_SIZE] { }; char buf[BUF_SIZE] { };
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
Genode::String_console sc(buf, BUF_SIZE); Format::String_console sc(buf, BUF_SIZE);
sc.vprintf(fmt, args); sc.vprintf(fmt, args);
Genode::log(Genode::Cstring(buf)); Genode::log(Genode::Cstring(buf));
va_end(args); va_end(args);
@ -169,7 +172,7 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
Genode::String_console sc(buf, size); Format::String_console sc(buf, size);
sc.vprintf(fmt, args); sc.vprintf(fmt, args);
va_end(args); va_end(args);
@ -1056,7 +1059,7 @@ void error_setg(Error **errp, const char *fmt, ...)
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
Genode::String_console sc(e->string, sizeof(e->string)); Format::String_console sc(e->string, sizeof(e->string));
sc.vprintf(fmt, args); sc.vprintf(fmt, args);
va_end(args); va_end(args);
} }

View File

@ -12,8 +12,11 @@
*/ */
/* Genode includes */ /* Genode includes */
#include <base/snprintf.h> #include <util/string.h>
#include <base/env.h> #include <base/log.h>
/* format-string includes */
#include <format/snprintf.h>
extern "C" { extern "C" {
@ -27,7 +30,7 @@ extern "C" {
va_start(list, format); va_start(list, format);
char buf[128] { }; char buf[128] { };
Genode::String_console(buf, sizeof(buf)).vprintf(format, list); Format::String_console(buf, sizeof(buf)).vprintf(format, list);
Genode::log(Genode::Cstring(buf)); Genode::log(Genode::Cstring(buf));
va_end(list); va_end(list);

View File

@ -23,6 +23,9 @@
#include <base/registry.h> #include <base/registry.h>
#include <base/log.h> #include <base/log.h>
/* format-string includes */
#include <format/snprintf.h>
/* LwIP includes */ /* LwIP includes */
#include <lwip_genode_init.h> #include <lwip_genode_init.h>
#include <nic_netif.h> #include <nic_netif.h>
@ -329,7 +332,7 @@ struct Lwip::Socket_dir : Lwip::Directory
{ {
char buf[Socket_name::capacity()]; char buf[Socket_name::capacity()];
return Socket_name(Genode::Cstring( return Socket_name(Genode::Cstring(
buf, Genode::snprintf(buf, Socket_name::capacity(), "%x", num))); buf, Format::snprintf(buf, Socket_name::capacity(), "%x", num)));
} }
Genode::Allocator &alloc; Genode::Allocator &alloc;
@ -920,7 +923,7 @@ class Lwip::Udp_socket_dir final :
return Read_result::READ_ERR_INVALID; return Read_result::READ_ERR_INVALID;
char const *ip_str = ipaddr_ntoa(&_pcb->local_ip); char const *ip_str = ipaddr_ntoa(&_pcb->local_ip);
/* TODO: [IPv6]:port */ /* TODO: [IPv6]:port */
out_count = Genode::snprintf(dst.start, dst.num_bytes, "%s:%d\n", out_count = Format::snprintf(dst.start, dst.num_bytes, "%s:%d\n",
ip_str, _pcb->local_port); ip_str, _pcb->local_port);
return Read_result::READ_OK; return Read_result::READ_OK;
} }
@ -928,9 +931,9 @@ class Lwip::Udp_socket_dir final :
case Lwip_file_handle::CONNECT: { case Lwip_file_handle::CONNECT: {
/* check if the PCB was connected */ /* check if the PCB was connected */
if (!ip_addr_isany(&_pcb->remote_ip)) if (!ip_addr_isany(&_pcb->remote_ip))
out_count = Genode::snprintf(dst.start, dst.num_bytes, "connected"); out_count = Format::snprintf(dst.start, dst.num_bytes, "connected");
else else
out_count = Genode::snprintf(dst.start, dst.num_bytes, "not connected"); out_count = Format::snprintf(dst.start, dst.num_bytes, "not connected");
return Read_result::READ_OK; return Read_result::READ_OK;
} }
@ -943,14 +946,14 @@ class Lwip::Udp_socket_dir final :
_packet_queue.head([&] (Packet &pkt) { _packet_queue.head([&] (Packet &pkt) {
char const *ip_str = ipaddr_ntoa(&pkt.addr); char const *ip_str = ipaddr_ntoa(&pkt.addr);
/* TODO: IPv6 */ /* TODO: IPv6 */
out_count = Genode::snprintf(dst.start, dst.num_bytes, "%s:%d\n", out_count = Format::snprintf(dst.start, dst.num_bytes, "%s:%d\n",
ip_str, pkt.port); ip_str, pkt.port);
result = Read_result::READ_OK; result = Read_result::READ_OK;
}); });
} else { } else {
char const *ip_str = ipaddr_ntoa(&_pcb->remote_ip); char const *ip_str = ipaddr_ntoa(&_pcb->remote_ip);
/* TODO: [IPv6]:port */ /* TODO: [IPv6]:port */
out_count = Genode::snprintf(dst.start, dst.num_bytes, "%s:%d\n", out_count = Format::snprintf(dst.start, dst.num_bytes, "%s:%d\n",
ip_str, _pcb->remote_port); ip_str, _pcb->remote_port);
result = Read_result::READ_OK; result = Read_result::READ_OK;
} }
@ -960,7 +963,7 @@ class Lwip::Udp_socket_dir final :
/* /*
* Print the location of this socket directory * Print the location of this socket directory
*/ */
out_count = Genode::snprintf(dst.start, dst.num_bytes, "udp/%s\n", out_count = Format::snprintf(dst.start, dst.num_bytes, "udp/%s\n",
name().string()); name().string());
return Read_result::READ_OK; return Read_result::READ_OK;
break; break;
@ -1354,7 +1357,7 @@ class Lwip::Tcp_socket_dir final :
return Read_result::READ_ERR_INVALID; return Read_result::READ_ERR_INVALID;
char const *ip_str = ipaddr_ntoa(&_pcb->remote_ip); char const *ip_str = ipaddr_ntoa(&_pcb->remote_ip);
/* TODO: [IPv6]:port */ /* TODO: [IPv6]:port */
out_count = Genode::snprintf(dst.start, dst.num_bytes, "%s:%d\n", out_count = Format::snprintf(dst.start, dst.num_bytes, "%s:%d\n",
ip_str, _pcb->remote_port); ip_str, _pcb->remote_port);
return Read_result::READ_OK; return Read_result::READ_OK;
} else { } else {
@ -1392,7 +1395,7 @@ class Lwip::Tcp_socket_dir final :
/* /*
* Print the location of this socket directory * Print the location of this socket directory
*/ */
out_count = Genode::snprintf(dst.start, dst.num_bytes, "tcp/%s\n", out_count = Format::snprintf(dst.start, dst.num_bytes, "tcp/%s\n",
name().string()); name().string());
return Read_result::READ_OK; return Read_result::READ_OK;
break; break;
@ -1405,7 +1408,7 @@ class Lwip::Tcp_socket_dir final :
for (Pcb_pending *p = _pcb_pending.first(); p; p = p->next()) for (Pcb_pending *p = _pcb_pending.first(); p; p = p->next())
++pending_count; ++pending_count;
out_count = Genode::snprintf(dst.start, dst.num_bytes, "%d\n", pending_count); out_count = Format::snprintf(dst.start, dst.num_bytes, "%d\n", pending_count);
return Read_result::READ_OK; return Read_result::READ_OK;
} }
@ -1416,7 +1419,7 @@ class Lwip::Tcp_socket_dir final :
return Read_result::READ_ERR_INVALID; return Read_result::READ_ERR_INVALID;
char const *ip_str = ipaddr_ntoa(&_pcb->local_ip); char const *ip_str = ipaddr_ntoa(&_pcb->local_ip);
/* TODO: [IPv6]:port */ /* TODO: [IPv6]:port */
out_count = Genode::snprintf(dst.start, dst.num_bytes, out_count = Format::snprintf(dst.start, dst.num_bytes,
"%s:%d\n", ip_str, _pcb->local_port); "%s:%d\n", ip_str, _pcb->local_port);
return Read_result::READ_OK; return Read_result::READ_OK;
} }
@ -1425,10 +1428,10 @@ class Lwip::Tcp_socket_dir final :
case Lwip_file_handle::CONNECT: case Lwip_file_handle::CONNECT:
switch (state) { switch (state) {
case READY: case READY:
out_count = Genode::snprintf(dst.start, dst.num_bytes, "connected"); out_count = Format::snprintf(dst.start, dst.num_bytes, "connected");
break; break;
default: default:
out_count = Genode::snprintf(dst.start, dst.num_bytes, "connection refused"); out_count = Format::snprintf(dst.start, dst.num_bytes, "connection refused");
break; break;
} }
return Read_result::READ_OK; return Read_result::READ_OK;

View File

@ -17,6 +17,7 @@
#include <base/heap.h> #include <base/heap.h>
#include <libc/component.h> #include <libc/component.h>
#include <base/shared_object.h> #include <base/shared_object.h>
#include <format/snprintf.h>
using namespace Genode; using namespace Genode;
@ -126,7 +127,7 @@ static void test_stack_align(char const *fmt, ...)
va_start(list, fmt); va_start(list, fmt);
char buf[128] { }; char buf[128] { };
String_console(buf, sizeof(buf)).vprintf(fmt, list); Format::String_console(buf, sizeof(buf)).vprintf(fmt, list);
log(Cstring(buf)); log(Cstring(buf));
va_end(list); va_end(list);

View File

@ -1,6 +1,6 @@
SRC_CC = main.cc SRC_CC = main.cc
TARGET = test-ldso TARGET = test-ldso
LIBS = base test-ldso_lib_1 test-ldso_lib_2 libc libm LIBS = base test-ldso_lib_1 test-ldso_lib_2 libc libm format
INC_DIR += $(REP_DIR)/src/test/ldso/include INC_DIR += $(REP_DIR)/src/test/ldso/include
CC_CXX_WARN_STRICT = CC_CXX_WARN_STRICT =

View File

@ -20,3 +20,4 @@ vfs
nitpicker_gfx nitpicker_gfx
blit blit
libyuv libyuv
format

View File

@ -20,3 +20,4 @@ vm_session
nitpicker_gfx nitpicker_gfx
blit blit
libyuv libyuv
format

View File

@ -17,3 +17,4 @@ usb_session
vfs vfs
vm_session vm_session
libyuv libyuv
format