akaros/tools/compilers/gcc-glibc/glibc-2.19-existing.patch
<<
>>
Prefs
   1diff -ruB --unidirectional-new-file ../glibc-2.19/abi-tags ../glibc-2.19-akaros/abi-tags
   2--- glibc-2.19/abi-tags 2014-02-07 04:04:38.000000000 -0500
   3+++ glibc-2.19-akaros/abi-tags  2015-12-17 14:58:45.065386401 -0500
   4@@ -28,5 +28,7 @@
   5 
   6 .*-.*-syllable.*       5       2.0.0   # just an arbitrary value
   7 
   8+.*-.*-akaros.*         6       1.0.0   # just an arbitrary value
   9+
  10 # There is no catch-all default here because every supported OS that uses
  11 # ELF must have its own unique ABI tag.
  12diff -ruB --unidirectional-new-file ../glibc-2.19/configure ../glibc-2.19-akaros/configure
  13--- glibc-2.19/configure        2014-02-07 04:04:38.000000000 -0500
  14+++ glibc-2.19-akaros/configure 2015-12-17 14:58:45.065386401 -0500
  15@@ -4121,6 +4121,16 @@
  16   tail="$2"
  17 done
  18 
  19+# For akaros, we don't have a base OS, which messes things up. Change this for
  20+# the purpose of sysdeps detection.
  21+test "x$base_os" != x || case "$os" in
  22+akaros*)
  23+  base=/akaros
  24+  vendor=
  25+  ostry=
  26+  ;;
  27+esac
  28+
  29 # For sparc/sparc32, try sparc/sparc32 and then sparc.
  30 mach=
  31 tail=$machine${submachine:+/$submachine}
  32diff -ruB --unidirectional-new-file ../glibc-2.19/configure.ac ../glibc-2.19-akaros/configure.ac
  33--- glibc-2.19/configure.ac     2014-02-07 04:04:38.000000000 -0500
  34+++ glibc-2.19-akaros/configure.ac      2015-12-17 14:58:45.065386401 -0500
  35@@ -722,6 +722,16 @@
  36   tail="$2"
  37 done
  38 
  39+# For akaros, we don't have a base OS, which messes things up. Change this for
  40+# the purpose of sysdeps detection.
  41+test "x$base_os" != x || case "$os" in
  42+akaros*)
  43+  base=/akaros
  44+  vendor=
  45+  ostry=
  46+  ;;
  47+esac
  48+
  49 # For sparc/sparc32, try sparc/sparc32 and then sparc.
  50 mach=
  51 tail=$machine${submachine:+/$submachine}
  52diff -ruB --unidirectional-new-file ../glibc-2.19/elf/Makefile ../glibc-2.19-akaros/elf/Makefile
  53--- glibc-2.19/elf/Makefile     2014-02-07 04:04:38.000000000 -0500
  54+++ glibc-2.19-akaros/elf/Makefile      2015-12-17 14:58:45.065386401 -0500
  55@@ -24,7 +24,7 @@
  56 headers                = elf.h bits/elfclass.h link.h bits/link.h
  57 routines       = $(dl-routines) dl-support dl-iteratephdr \
  58                  dl-addr enbl-secure dl-profstub \
  59-                 dl-origin dl-libc dl-sym dl-tsd dl-sysdep
  60+                 dl-origin dl-libc dl-sym dl-tsd #dl-sysdep
  61 
  62 # The core dynamic linking functions are in libc for the static and
  63 # profiled libraries.
  64diff -ruB --unidirectional-new-file ../glibc-2.19/include/alloca.h ../glibc-2.19-akaros/include/alloca.h
  65--- glibc-2.19/include/alloca.h 2014-02-07 04:04:38.000000000 -0500
  66+++ glibc-2.19-akaros/include/alloca.h  2016-10-05 17:05:34.571879935 -0400
  67@@ -1,5 +1,7 @@
  68 #ifndef _ALLOCA_H
  69 
  70+/* AKAROS: Modified the alloca cutoff */
  71+
  72 #include <stdlib/alloca.h>
  73 #include <stackinfo.h>
  74 
  75@@ -16,7 +18,10 @@
  76 extern int __libc_alloca_cutoff (size_t size) __attribute__ ((const));
  77 libc_hidden_proto (__libc_alloca_cutoff)
  78 
  79-#define __MAX_ALLOCA_CUTOFF    65536
  80+/* AKAROS: Limit to a small amount, so 2LSs and vcore context can have small
  81+ * stacks.  Glibc typically uses 1/4 of the stack.  Assuming our users have at
  82+ * least 4K stacks, we can use 1k, but let's be paranoid and use 512 for now. */
  83+#define __MAX_ALLOCA_CUTOFF    512
  84 
  85 #include <allocalim.h>
  86 
  87diff -ruB --unidirectional-new-file ../glibc-2.19/include/errno.h ../glibc-2.19-akaros/include/errno.h
  88--- glibc-2.19/include/errno.h  2014-02-07 04:04:38.000000000 -0500
  89+++ glibc-2.19-akaros/include/errno.h   2015-12-17 14:58:45.065386401 -0500
  90@@ -1,3 +1,5 @@
  91+/* Modified for Akaros, removed the redefinition of errno */
  92+
  93 #ifndef _ERRNO_H
  94 
  95 #include <stdlib/errno.h>
  96@@ -21,13 +23,16 @@
  97 
  98 #  include <tls.h>
  99 
 100-#  undef  errno
 101-#  ifndef NOT_IN_libc
 102-#   define errno __libc_errno
 103-#  else
 104-#   define errno errno         /* For #ifndef errno tests.  */
 105-#  endif
 106+/* AKAROS doesn't want the redef of errno */
 107+#  ifndef __akaros__
 108+#    undef  errno
 109+#    ifndef NOT_IN_libc
 110+#     define errno __libc_errno
 111+#    else
 112+#     define errno errno               /* For #ifndef errno tests.  */
 113+#    endif
 114 extern __thread int errno attribute_tls_model_ie;
 115+#  endif
 116 
 117 # endif        /* !NOT_IN_libc || IN_LIB */
 118 
 119diff -ruB --unidirectional-new-file ../glibc-2.19/include/libc-symbols.h ../glibc-2.19-akaros/include/libc-symbols.h
 120--- glibc-2.19/include/libc-symbols.h   2014-02-07 04:04:38.000000000 -0500
 121+++ glibc-2.19-akaros/include/libc-symbols.h    2016-02-16 11:25:16.761066328 -0500
 122@@ -1,3 +1,5 @@
 123+/* Modified for Akaros, removed the static_link_warning() */
 124+
 125 /* Support macros for making weak and strong aliases for symbols,
 126    and for using symbol sets and linker warnings with GNU ld.
 127    Copyright (C) 1995-2014 Free Software Foundation, Inc.
 128@@ -231,6 +233,14 @@
 129   link_warning (name, #name " is not implemented and will always fail")
 130 
 131 /* Warning for linking functions calling dlopen into static binaries.  */
 132+
 133+/* AKAROS doesn't want the annoying warning, breaks -Werror. */
 134+#ifdef __akaros__
 135+
 136+#define static_link_warning(name)
 137+
 138+#else
 139+
 140 #ifdef SHARED
 141 #define static_link_warning(name)
 142 #else
 143@@ -241,6 +251,8 @@
 144 for linking")
 145 #endif
 146 
 147+#endif /* __akaros__ */
 148+
 149 /* Declare SYMBOL to be TYPE (`function' or `object') of SIZE bytes
 150    alias to ORIGINAL, when the assembler supports such declarations
 151    (such as in ELF).
 152diff -ruB --unidirectional-new-file ../glibc-2.19/Makeconfig ../glibc-2.19-akaros/Makeconfig
 153--- glibc-2.19/Makeconfig       2014-02-07 04:04:38.000000000 -0500
 154+++ glibc-2.19-akaros/Makeconfig        2015-12-17 14:58:45.065386401 -0500
 155@@ -493,13 +493,17 @@
 156 LDFLAGS-rdynamic = -rdynamic
 157 LDFLAGS-Bsymbolic = -Bsymbolic
 158 
 159-# Choose the default search path for the dynamic linker based on
 160-# where we will install libraries.
 161-ifneq ($(libdir),$(slibdir))
 162-default-rpath = $(slibdir):$(libdir)
 163-else
 164-default-rpath = $(libdir)
 165-endif
 166+# For akaros we want the default-rpath to be the path on our resulting
 167+# machine, not the path of the lib directory in our cross compiler
 168+default-rpath = "/lib"
 169+
 170+## Choose the default search path for the dynamic linker based on
 171+## where we will install libraries.
 172+#ifneq ($(libdir),$(slibdir))
 173+#default-rpath = $(slibdir):$(libdir)
 174+#else
 175+#default-rpath = $(libdir)
 176+#endif
 177 
 178 ifndef link-extra-libs
 179 link-extra-libs = $(LDLIBS-$(@F))
 180@@ -1028,10 +1032,12 @@
 181 # These are the subdirectories containing the library source.  The order
 182 # is more or less arbitrary.  The sorting step will take care of the
 183 # dependencies.
 184+#
 185+# AKAROS_PORT removed gshadow.  relies on NSS, has no man interface
 186 all-subdirs = csu assert ctype locale intl catgets math setjmp signal      \
 187              stdlib stdio-common libio malloc string wcsmbs time dirent    \
 188              grp pwd posix io termios resource misc socket sysvipc gmon    \
 189-             gnulib iconv iconvdata wctype manual shadow gshadow po argp   \
 190+             gnulib iconv iconvdata wctype manual shadow po argp   \
 191              crypt localedata timezone rt conform debug                    \
 192              $(add-on-subdirs) dlfcn elf
 193 
 194diff -ruB --unidirectional-new-file ../glibc-2.19/nptl/shlib-versions ../glibc-2.19-akaros/nptl/shlib-versions
 195--- glibc-2.19/nptl/shlib-versions      2014-02-07 04:04:38.000000000 -0500
 196+++ glibc-2.19-akaros/nptl/shlib-versions       2015-12-17 14:58:45.065386401 -0500
 197@@ -3,4 +3,6 @@
 198 s390x-.*-linux.*       libpthread=0            GLIBC_2.2
 199 powerpc64-.*-linux.*   libpthread=0            GLIBC_2.3
 200 powerpc.*le-.*-linux.* libpthread=0            GLIBC_2.17
 201+#x86_64-.*-akaros.*      libpthread=0        GLIBC_2.2.5
 202 .*-.*-linux.*          libpthread=0
 203+.*-.*-akaros.*         libpthread=0
 204diff -ruB --unidirectional-new-file ../glibc-2.19/rt/Makefile ../glibc-2.19-akaros/rt/Makefile
 205--- glibc-2.19/rt/Makefile      2014-02-07 04:04:38.000000000 -0500
 206+++ glibc-2.19-akaros/rt/Makefile       2015-12-17 14:58:45.065386401 -0500
 207@@ -53,7 +53,7 @@
 208         tst-cputimer1 tst-cputimer2 tst-cputimer3 \
 209         tst-clock2
 210 
 211-extra-libs := librt
 212+extra-libs := #librt
 213 extra-libs-others := $(extra-libs)
 214 
 215 include ../Rules
 216diff -ruB --unidirectional-new-file ../glibc-2.19/scripts/config.sub ../glibc-2.19-akaros/scripts/config.sub
 217--- glibc-2.19/scripts/config.sub       2014-02-07 04:04:38.000000000 -0500
 218+++ glibc-2.19-akaros/scripts/config.sub        2015-12-17 14:58:45.065386401 -0500
 219@@ -117,7 +117,7 @@
 220 case $maybe_os in
 221   nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
 222   linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
 223-  knetbsd*-gnu* | netbsd*-gnu* | \
 224+  knetbsd*-gnu* | netbsd*-gnu* | akaros*-gnu* | \
 225   kopensolaris*-gnu* | \
 226   storm-chaos* | os2-emx* | rtmk-nova*)
 227     os=-$maybe_os
 228@@ -1356,7 +1356,7 @@
 229              | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
 230              | -sym* | -kopensolaris* | -plan9* \
 231              | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
 232-             | -aos* | -aros* \
 233+             | -aos* | -aros* | -akaros* \
 234              | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 235              | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
 236              | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
 237diff -ruB --unidirectional-new-file ../glibc-2.19/shlib-versions ../glibc-2.19-akaros/shlib-versions
 238--- glibc-2.19/shlib-versions   2014-02-07 04:04:38.000000000 -0500
 239+++ glibc-2.19-akaros/shlib-versions    2015-12-17 14:58:45.065386401 -0500
 240@@ -24,6 +24,7 @@
 241 s390x-.*-linux.*        DEFAULT                        GLIBC_2.2
 242 powerpc64-.*-linux.*   DEFAULT                 GLIBC_2.3
 243 powerpc.*le-.*-linux.* DEFAULT                 GLIBC_2.17
 244+x86_64-.*-akaros.*      DEFAULT                        GLIBC_2.2.5
 245 .*-.*-gnu-gnu.*                DEFAULT                 GLIBC_2.2.6
 246 
 247 # Configuration                ABI                     Identifier for ABI data files
 248@@ -44,6 +45,7 @@
 249 sh.*-.*-linux.*                libc=6                  GLIBC_2.2
 250 sparc64.*-.*-linux.*   libc=6                  GLIBC_2.2
 251 .*-.*-linux.*          libc=6
 252+.*-.*-akaros.*         libc=6
 253 
 254 # libmachuser.so.1 corresponds to mach/*.defs as of Utah's UK22 release.
 255 .*-.*-gnu-gnu.*                libmachuser=1
 256diff -ruB --unidirectional-new-file ../glibc-2.19/sunrpc/netname.c ../glibc-2.19-akaros/sunrpc/netname.c
 257--- glibc-2.19/sunrpc/netname.c 2014-02-07 04:04:38.000000000 -0500
 258+++ glibc-2.19-akaros/sunrpc/netname.c  2015-12-17 14:58:45.065386401 -0500
 259@@ -16,13 +16,13 @@
 260    License along with the GNU C Library; if not, see
 261    <http://www.gnu.org/licenses/>.  */
 262 
 263+/* AKAROS_PORT: removed references to nss; stubbed the funcs that used it. */
 264+
 265 #include <stdio.h>
 266 #include <unistd.h>
 267 #include <string.h>
 268 #include <rpc/rpc.h>
 269 
 270-#include "nsswitch.h"
 271-
 272 #define        OPSYS_LEN 4
 273 #define        MAXIPRINT (11)          /* max length of printed integer */
 274 static const char OPSYS[] = "unix";
 275@@ -139,56 +139,18 @@
 276 /* Type of the lookup function for netname2user.  */
 277 typedef int (*netname2user_function) (const char netname[MAXNETNAMELEN + 1],
 278                                      uid_t *, gid_t *, int *, gid_t *);
 279-/* The lookup function for the first entry of this service.  */
 280-extern int __nss_publickey_lookup (service_user ** nip, const char *name,
 281-                                  void **fctp) internal_function;
 282-
 283 int
 284 netname2user (const char netname[MAXNETNAMELEN + 1], uid_t * uidp, gid_t * gidp,
 285              int *gidlenp, gid_t * gidlist)
 286 {
 287-  static service_user *startp;
 288-  static netname2user_function start_fct;
 289-  service_user *nip;
 290-  union
 291-  {
 292-    netname2user_function f;
 293-    void *ptr;
 294-  } fct;
 295-  enum nss_status status = NSS_STATUS_UNAVAIL;
 296-  int no_more;
 297-
 298-  if (startp == NULL)
 299-    {
 300-      no_more = __nss_publickey_lookup (&nip, "netname2user", &fct.ptr);
 301-      if (no_more)
 302-       startp = (service_user *) - 1;
 303-      else
 304-       {
 305-         startp = nip;
 306-         start_fct = fct.f;
 307-       }
 308-    }
 309-  else
 310-    {
 311-      fct.f = start_fct;
 312-      no_more = (nip = startp) == (service_user *) - 1;
 313-    }
 314-
 315-  while (!no_more)
 316-    {
 317-      status = (*fct.f) (netname, uidp, gidp, gidlenp, gidlist);
 318-
 319-      no_more = __nss_next2 (&nip, "netname2user", NULL, &fct.ptr, status, 0);
 320-    }
 321-
 322-  return status == NSS_STATUS_SUCCESS;
 323+  return FALSE;
 324 }
 325 #ifdef EXPORT_RPC_SYMBOLS
 326 libc_hidden_def (netname2user)
 327 #else
 328 libc_hidden_nolink_sunrpc (netname2user, GLIBC_2_1)
 329 #endif
 330+stub_warning(netname2user)
 331 
 332 int
 333 netname2host (const char netname[MAXNETNAMELEN + 1], char *hostname,
 334diff -ruB --unidirectional-new-file ../glibc-2.19/sysdeps/i386/configure ../glibc-2.19-akaros/sysdeps/i386/configure
 335--- glibc-2.19/sysdeps/i386/configure   2014-02-07 04:04:38.000000000 -0500
 336+++ glibc-2.19-akaros/sysdeps/i386/configure    2015-12-17 14:58:45.077386468 -0500
 337@@ -82,13 +82,13 @@
 338 $as_echo "$libc_compiler_builtin_inlined" >&6; }
 339 
 340 
 341-ac_fn_c_check_header_compile "$LINENO" "cpuid.h" "ac_cv_header_cpuid_h" "/* No default includes.  */
 342-"
 343-if test "x$ac_cv_header_cpuid_h" = xyes; then :
 344-
 345-else
 346-  as_fn_error $? "gcc must provide the <cpuid.h> header" "$LINENO" 5
 347-fi
 348+#ac_fn_c_check_header_compile "$LINENO" "cpuid.h" "ac_cv_header_cpuid_h" "/* No default includes.  */
 349+#"
 350+#if test "x$ac_cv_header_cpuid_h" = xyes; then :
 351+#
 352+#else
 353+#  as_fn_error $? "gcc must provide the <cpuid.h> header" "$LINENO" 5
 354+#fi
 355 
 356 
 357 
 358diff -ruB --unidirectional-new-file ../glibc-2.19/sysdeps/i386/configure.ac ../glibc-2.19-akaros/sysdeps/i386/configure.ac
 359--- glibc-2.19/sysdeps/i386/configure.ac        2014-02-07 04:04:38.000000000 -0500
 360+++ glibc-2.19-akaros/sysdeps/i386/configure.ac 2015-12-17 14:58:45.077386468 -0500
 361@@ -30,9 +30,9 @@
 362 *** Please use host i786, i686, i586, or i486.
 363 *** For example: /source/glibc/configure CFLAGS='-O2 -march=i686' ...])])
 364 
 365-AC_CHECK_HEADER([cpuid.h], ,
 366-  [AC_MSG_ERROR([gcc must provide the <cpuid.h> header])],
 367-  [/* No default includes.  */])
 368+#AC_CHECK_HEADER([cpuid.h], ,
 369+#  [AC_MSG_ERROR([gcc must provide the <cpuid.h> header])],
 370+#  [/* No default includes.  */])
 371 
 372 dnl Check if -msse4 works.
 373 AC_CACHE_CHECK(for SSE4 support, libc_cv_cc_sse4, [dnl
 374diff -ruB --unidirectional-new-file ../glibc-2.19/sysdeps/i386/tlsdesc.sym ../glibc-2.19-akaros/sysdeps/i386/tlsdesc.sym
 375--- glibc-2.19/sysdeps/i386/tlsdesc.sym 2014-02-07 04:04:38.000000000 -0500
 376+++ glibc-2.19-akaros/sysdeps/i386/tlsdesc.sym  2015-12-17 14:58:45.077386468 -0500
 377@@ -8,7 +8,7 @@
 378 
 379 -- Abuse tls.h macros to derive offsets relative to the thread register.
 380 
 381-DTV_OFFSET                     offsetof(struct pthread, header.dtv)
 382+DTV_OFFSET                     offsetof(struct rthread, header.dtv)
 383 
 384 TLSDESC_ARG                    offsetof(struct tlsdesc, arg)
 385 
 386diff -ruB --unidirectional-new-file ../glibc-2.19/sysdeps/x86_64/tlsdesc.sym ../glibc-2.19-akaros/sysdeps/x86_64/tlsdesc.sym
 387--- glibc-2.19/sysdeps/x86_64/tlsdesc.sym       2014-02-07 04:04:38.000000000 -0500
 388+++ glibc-2.19-akaros/sysdeps/x86_64/tlsdesc.sym        2015-12-17 14:58:45.077386468 -0500
 389@@ -8,7 +8,7 @@
 390 
 391 -- Abuse tls.h macros to derive offsets relative to the thread register.
 392 
 393-DTV_OFFSET                     offsetof(struct pthread, header.dtv)
 394+DTV_OFFSET                     offsetof(struct rthread, header.dtv)
 395 
 396 TLSDESC_ARG                    offsetof(struct tlsdesc, arg)
 397 
 398--- glibc-2.19/assert/assert.c  2017-04-25 12:52:32.624619029 -0400
 399+++ glibc-2.19-akaros/assert/assert.c   2017-04-25 12:53:43.872966850 -0400
 400@@ -24,6 +24,7 @@
 401 #include <sysdep.h>
 402 #include <unistd.h>
 403 #include <sys/mman.h>
 404+#include <parlib/assert.h>
 405 
 406 
 407 extern const char *__progname;
 408@@ -98,7 +99,7 @@
 409 __assert_fail (const char *assertion, const char *file, unsigned int line,
 410               const char *function)
 411 {
 412-  __assert_fail_base (_("%s%s%s:%u: %s%sAssertion `%s' failed.\n%n"),
 413-                     assertion, file, line, function);
 414+  /* Calls out to parlib, and this never returns */
 415+  _assert_failed(file, line, assertion);
 416 }
 417 hidden_def(__assert_fail)
 418--- glibc-2.19/stdlib/exit.c    2017-06-08 17:05:17.558550998 -0400
 419+++ glibc-2.19-akaros/stdlib/exit.c     2017-06-08 17:04:50.574432434 -0400
 420@@ -19,6 +19,7 @@
 421 #include <stdlib.h>
 422 #include <unistd.h>
 423 #include <sysdep.h>
 424+#include <parlib/vcore.h>
 425 #include "exit.h"
 426 
 427 #include "set-hooks.h"
 428@@ -101,6 +102,8 @@
 429 void
 430 exit (int status)
 431 {
 432+  if (in_vcore_context())
 433+    _exit(status);
 434   __run_exit_handlers (status, &__exit_funcs, true);
 435 }
 436 libc_hidden_def (exit)
 437diff -ruB --unidirectional-new-file ../glibc-2.19/stdio-common/vfprintf.c ../glibc-2.19-akaros/stdio-common/vfprintf.c
 438--- glibc-2.19/stdio-common/vfprintf.c  2014-02-07 04:04:38.000000000 -0500
 439+++ glibc-2.19-akaros/stdio-common/vfprintf.c   2017-07-31 16:49:00.835618991 -0400
 440@@ -30,6 +30,38 @@
 441 #include <locale/localeinfo.h>
 442 #include <stdio.h>
 443 
 444+#include <ros/common.h>
 445+#include <sys/mman.h>
 446+#include <parlib/vcore.h>
 447+#include <unistd.h>
 448+
 449+/* Modified for AKAROS, uses mmap in place of large stack allocations */
 450+static const char *failmsg = "vfprintf mmap failed!";
 451+
 452+static inline __attribute__((always_inline)) void *safe_alloc(size_t amt)
 453+{
 454+       void *buf;
 455+
 456+       if (in_vcore_context()) {
 457+               buf = mmap(0, ROUNDUP(amt, PGSIZE), PROT_WRITE | PROT_READ,
 458+                          MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
 459+               if (buf == MAP_FAILED) {
 460+                       write(2, failmsg, sizeof(failmsg));
 461+                       exit(-1);
 462+               }
 463+               return buf;
 464+       } else {
 465+               /* This might have issues.  Might have to use macros. */
 466+               return alloca(amt);
 467+       }
 468+}
 469+
 470+static inline void safe_free(void *buf, size_t amt)
 471+{
 472+       if (in_vcore_context())
 473+       munmap(buf, ROUNDUP(amt, PGSIZE));
 474+}
 475+
 476 /* This code is shared between the standard stdio implementation found
 477    in GNU C library and the libio implementation originally found in
 478    GNU libg++.
 479@@ -246,6 +278,8 @@
 480   CHAR_T work_buffer[1000];
 481   CHAR_T *workstart = NULL;
 482   CHAR_T *workend;
 483+  /* AKAROS: this might get mmaped */
 484+  void *specs_buf = NULL;
 485 
 486   /* We have to save the original argument pointer.  */
 487   va_list ap_save;
 488@@ -1678,7 +1712,13 @@
 489     size_t nspecs = 0;
 490     /* A more or less arbitrary start value.  */
 491     size_t nspecs_size = 32 * sizeof (struct printf_spec);
 492-    struct printf_spec *specs = alloca (nspecs_size);
 493+
 494+       /* AKAROS: specs_buf declared above and conditionally freed below */
 495+    //struct printf_spec *specs = alloca (nspecs_size);
 496+    struct printf_spec *specs;
 497+
 498+    specs_buf = safe_alloc(nspecs_size);
 499+       specs = (struct printf_spec*)specs_buf;
 500 
 501     /* The number of arguments the format string requests.  This will
 502        determine the size of the array needed to store the argument
 503@@ -2049,6 +2089,8 @@
 504     free (args_malloced);
 505   if (__glibc_unlikely (workstart != NULL))
 506     free (workstart);
 507+  if (specs_buf)
 508+    safe_free(specs_buf, 32 * sizeof(struct printf_spec));
 509   /* Unlock the stream.  */
 510   _IO_funlockfile (s);
 511   _IO_cleanup_region_end (0);
 512@@ -2276,7 +2318,12 @@
 513 buffered_vfprintf (_IO_FILE *s, const CHAR_T *format,
 514                   _IO_va_list args)
 515 {
 516-  CHAR_T buf[_IO_BUFSIZ];
 517+  /* AKAROS: mmap the buf.  */
 518+  //CHAR_T buf[_IO_BUFSIZ];
 519+  CHAR_T *buf;
 520+
 521+  buf = safe_alloc(_IO_BUFSIZ);
 522+
 523   struct helper_file helper;
 524   _IO_FILE *hp = (_IO_FILE *) &helper._f;
 525   int result, to_flush;
 526@@ -2338,6 +2385,7 @@
 527   _IO_funlockfile (s);
 528   __libc_cleanup_region_end (0);
 529 
 530+  safe_free(buf, _IO_BUFSIZ);
 531   return result;
 532 }
 533 
 534