[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH 1/5] lib/nolibc: import asprintf from musl


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Wed, 1 Aug 2018 11:02:18 +0300
  • Cc: florian.schmidt@xxxxxxxxx, simon.kuenzer@xxxxxxxxx, yuri.volchkov@xxxxxxxxx
  • Delivery-date: Wed, 01 Aug 2018 08:02:37 +0000
  • Ironport-phdr: 9a23:gNft2B0fsjxcPWQjsmDT+DRfVm0co7zxezQtwd8ZseMRIvad9pjvdHbS+e9qxAeQG9mDtbQc06L/iOPJYSQ4+5GPsXQPItRndiQuroEopTEmG9OPEkbhLfTnPGQQFcVGU0J5rTngaRAGUMnxaEfPrXKs8DUcBgvwNRZvJuTyB4Xek9m72/q99pHPYghEniaxba9vJxiqsAvdsdUbj5F/Iagr0BvJpXVIe+VSxWx2IF+Yggjx6MSt8pN96ipco/0u+dJOXqX8ZKQ4UKdXDC86PGAv5c3krgfMQA2S7XYBSGoWkx5IAw/Y7BHmW5r6ryX3uvZh1CScIMb7S60/Vza/4KdxUBLmiDkJOSM3/m/UjcJ/jqxbrQm9qxBj2YPYfJuYOOZicq7bYNgURXBBXsFUVyFZHI68aJAPD/YAPeZesoLzoUYOrQOjBQKxA+7g1jhIhmTq3a071eQtCwXG3BE4H9ITq3nbsM71OL0KUeCo16bE1y/Db/RP1Dr79YPGfBchofSWUrJxd8rc0UwvFx7ejlWUsIDlOzKV2f8RvGSB6OpgT+2vhmg6oA9yujii3togh4bUio4PyV3J9T91zJgrKdC6UkJ2b8aoHIZfui2HLYd7QcMvT3t2tCs0xLAKo4O3cScUxJkh2hXRceaIc5KS7RLmTOuRJDB4i297d7+nnBay9FSgyvX7VsmpzFZGtipFncfItnAKzxHT9M2HReF8/kelwzqAyxvT5vtcIUApjqXXMYQhwrkompoSt0TMADP2lV3rgKKZa0ko4Oul5uT9brn4uJORNZV4hw/mPqQrgMO/AOA4MgYUX2ic/OSxzKHs/UriQLVWj/02lLPVsJTHJcQDu660GBNa0p055xanEjepy84UnWMALF5dYhKIk5DpO03SIPD/Ffq/hlWskDFqx/DBJb3tG4jCIWbdkLj/ebZw8EpcyAsozdBD/JJYEL4AL+z1WkPrs9zYFBA5ORSuw+n7ENV9yp8eWWWXD6+XNKPStkWI5uM1LOmKfoMVoyryK/gg5/7vkHA5hUQQfa+30pQLbHC3BO9pL1+Hbnrxmt0BC3sFvhIiTOz2j12PSSVTZ3e3X6I74DE3EoGmDZrdSYCrgb2Owj27E4ZQZm9YFl+MFW3neJ6eV/gSdSKYOtVhnSAcVbi9V48h0gmjtQ/ny7p9L+rY4DMYtZXn1Ndp5+3TlhYy9SJvAsSbzW6CU2V0kXkTSDMswq9/vB819lDW1Kl+gvtDUNBe+f5NegM7LoLHifx3DZb1QA2SUM2OTQONRc66ADd5as8p3pdaaEFmB9SkyBTexzeCCKRTj6GBQoYzpPGPl0PtLtpwni6VnJIqiEMrF5NC
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

Copied as it is from official musl git mirror
(git://git.musl-libc.org/musl)

Commit <f2c6dbe2442027ed8fe0fa869918e41f495534d8>

Original file locations:
- src/stdio/asprintf.c
- src/stdio/vasprintf.c

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
 lib/nolibc/asprintf.c  | 13 +++++++++++++
 lib/nolibc/vasprintf.c | 15 +++++++++++++++
 2 files changed, 28 insertions(+)
 create mode 100644 lib/nolibc/asprintf.c
 create mode 100644 lib/nolibc/vasprintf.c

diff --git a/lib/nolibc/asprintf.c b/lib/nolibc/asprintf.c
new file mode 100644
index 0000000..4ec8353
--- /dev/null
+++ b/lib/nolibc/asprintf.c
@@ -0,0 +1,13 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdarg.h>
+
+int asprintf(char **s, const char *fmt, ...)
+{
+       int ret;
+       va_list ap;
+       va_start(ap, fmt);
+       ret = vasprintf(s, fmt, ap);
+       va_end(ap);
+       return ret;
+}
diff --git a/lib/nolibc/vasprintf.c b/lib/nolibc/vasprintf.c
new file mode 100644
index 0000000..08251bc
--- /dev/null
+++ b/lib/nolibc/vasprintf.c
@@ -0,0 +1,15 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+
+int vasprintf(char **s, const char *fmt, va_list ap)
+{
+       va_list ap2;
+       va_copy(ap2, ap);
+       int l = vsnprintf(0, 0, fmt, ap2);
+       va_end(ap2);
+
+       if (l<0 || !(*s=malloc(l+1U))) return -1;
+       return vsnprintf(*s, l+1U, fmt, ap);
+}
-- 
2.11.0


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.