]> gcc.gnu.org Git - gcc.git/commitdiff
More stuff from Uli.
authorJeff Law <law@gcc.gnu.org>
Tue, 16 Sep 1997 16:11:13 +0000 (10:11 -0600)
committerJeff Law <law@gcc.gnu.org>
Tue, 16 Sep 1997 16:11:13 +0000 (10:11 -0600)
From-SVN: r15487

config/mt-linux [new file with mode: 0644]
libio/config/linuxlibc1.mt [new file with mode: 0644]
libio/stdio/obprintf.c [new file with mode: 0644]
libio/stdio/vasprintf.c [new file with mode: 0644]
libstdc++/config/linux.mt [new file with mode: 0644]

diff --git a/config/mt-linux b/config/mt-linux
new file mode 100644 (file)
index 0000000..bbd9792
--- /dev/null
@@ -0,0 +1,2 @@
+# When using glibc 2 on Linux we must always use vtable thunks.
+  CXXFLAGS=-O2 -g -fvtable-thunks
diff --git a/libio/config/linuxlibc1.mt b/libio/config/linuxlibc1.mt
new file mode 100644 (file)
index 0000000..ffda172
--- /dev/null
@@ -0,0 +1,26 @@
+# Since the Linux C library has libio, we have to be very careful.
+
+# By default, we build libio and use it.  If someone wants to not
+# build it, let them go to extra work.  The reason is that the user
+# may want a newer, bug fixed libio, also on a linux 1.0.8 system
+# things just won't build with the bottom section uncommented.
+
+# Comment this out to avoid including the stdio functions in libiostream.a:
+LIBIOSTREAM_OBJECTS = $(IO_OBJECTS) $(IOSTREAM_OBJECTS) $(STDIO_WRAP_OBJECTS) $(OSPRIM_OBJECTS)
+LIBIOSTREAM_DEP = $(LIBIOSTREAM_OBJECTS) stmp-stdio
+LIBIOSTREAM_USE = $(LIBIOSTREAM_OBJECTS) `cat stdio.list`
+
+# Comment the above and uncomment the below to use the code in the Linux libc:
+# We have _G_config.h in /usr/include.
+# _G_CONFIG_H=
+
+# We have those in libc.a.
+# IO_OBJECTS=
+# STDIO_WRAP_OBJECTS=
+# OSPRIM_OBJECTS=
+
+# We have the rest in /usr/include.
+# USER_INCLUDES=PlotFile.h SFile.h builtinbuf.h editbuf.h fstream.h \
+#      indstream.h iomanip.h iostream.h istream.h ostream.h \
+#      parsestream.h pfstream.h procbuf.h stdiostream.h stream.h \
+#      streambuf.h strfile.h strstream.h
diff --git a/libio/stdio/obprintf.c b/libio/stdio/obprintf.c
new file mode 100644 (file)
index 0000000..6b959e4
--- /dev/null
@@ -0,0 +1,168 @@
+/* Print output of stream to given obstack.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+
+#ifdef __STDC__
+#include <stdlib.h>
+#endif
+#include "libioP.h"
+#include <string.h>
+#include <errno.h>
+#include <obstack.h>
+#include <stdarg.h>
+
+
+struct _IO_obstack_file
+{
+  struct _IO_FILE file;
+  const void *vtable;
+  struct obstack *obstack;
+};
+
+
+static int
+_IO_obstack_overflow (_IO_FILE *fp, int c)
+{
+  struct obstack *obstack = ((struct _IO_obstack_file *) fp)->obstack;
+
+  /* Make room for another character.  This might as well allocate a
+     new chunk a memory and moves the old contents over.  */
+  if (c != EOF)
+    obstack_1grow (obstack, c);
+
+  /* Setup the buffer pointers again.  */
+  fp->_IO_write_base = obstack_base (obstack);
+  fp->_IO_write_ptr = obstack_next_free (obstack);
+  fp->_IO_write_end = fp->_IO_write_base + obstack_room (obstack);
+  /* Now allocate the rest of the current chunk.  */
+  obstack_blank_fast (obstack, fp->_IO_write_end - fp->_IO_write_ptr);
+
+  return c;
+}
+
+
+static _IO_size_t
+_IO_obstack_xsputn (_IO_FILE *fp, const void *data, _IO_size_t n)
+{
+  struct obstack *obstack = ((struct _IO_obstack_file *) fp)->obstack;
+
+  if (fp->_IO_write_ptr + n > fp->_IO_write_end)
+    {
+      /* We need some more memory.  First shrink the buffer to the
+        space we really currently need.  */
+      obstack_blank (obstack, fp->_IO_write_ptr - fp->_IO_write_end);
+
+      /* Now grow for N bytes.  */
+      obstack_blank (obstack, n);
+
+      /* Setup the buffer pointers again.  */
+      fp->_IO_write_base = obstack_base (obstack);
+      fp->_IO_write_ptr = obstack_next_free (obstack);
+      fp->_IO_write_end = (fp->_IO_write_base + obstack_room (obstack));
+      /* Now allocate the rest of the current chunk.  */
+      obstack_blank_fast (obstack, fp->_IO_write_end - fp->_IO_write_ptr);
+    }
+  else
+    {
+      memcpy (fp->_IO_write_ptr, data, n);
+      fp->_IO_write_ptr += n;
+    }
+
+  return n;
+}
+
+
+/* the jump table.  */
+static struct _IO_jump_t _IO_obstack_jumps =
+{
+  JUMP_INIT_DUMMY,
+  JUMP_INIT(finish, NULL),
+  JUMP_INIT(overflow, _IO_obstack_overflow),
+  JUMP_INIT(underflow, NULL),
+  JUMP_INIT(uflow, NULL),
+  JUMP_INIT(pbackfail, NULL),
+  JUMP_INIT(xsputn, _IO_obstack_xsputn),
+  JUMP_INIT(xsgetn, NULL),
+  JUMP_INIT(seekoff, NULL),
+  JUMP_INIT(seekpos, NULL),
+  JUMP_INIT(setbuf, NULL),
+  JUMP_INIT(sync, NULL),
+  JUMP_INIT(doallocate, NULL),
+  JUMP_INIT(read, NULL),
+  JUMP_INIT(write, NULL),
+  JUMP_INIT(seek, NULL),
+  JUMP_INIT(close, NULL),
+  JUMP_INIT(stat, NULL)
+};
+
+
+int
+_IO_obstack_vprintf (struct obstack *obstack, const char *format, va_list args)
+{
+  struct obstack_FILE
+    {
+      struct _IO_obstack_file ofile;
+#ifdef _IO_MTSAFE_IO
+      _IO_lock_t lock;
+#endif
+  } new_f;
+  int result;
+
+#ifdef _IO_MTSAFE_IO
+  new_f.ofile.file._lock = &new_f.lock;
+#endif
+
+  _IO_init ((_IO_FILE *) &new_f.ofile, 0);
+  _IO_JUMPS (&new_f.ofile.file) = &_IO_obstack_jumps;
+  _IO_str_init_static (&new_f.ofile.file, obstack_base (obstack),
+                      (obstack_object_size (obstack) +
+                       obstack_room (obstack)), obstack_next_free (obstack));
+  /* Now allocate the rest of the current chunk.  */
+  obstack_blank_fast (obstack,
+                     (new_f.ofile.file._IO_write_end
+                      - new_f.ofile.file._IO_write_ptr));
+  new_f.ofile.obstack = obstack;
+
+  result = _IO_vfprintf ((_IO_FILE *) &new_f, format, args);
+
+  /* Shrink the buffer to the space we really currently need.  */
+  obstack_blank (obstack, (new_f.ofile.file._IO_write_ptr
+                          - new_f.ofile.file._IO_write_end));
+
+  return result;
+}
+#ifdef weak_alias
+weak_alias (_IO_obstack_vprintf, obstack_vprintf)
+#endif
+
+
+int
+_IO_obstack_printf (struct obstack *obstack, const char *format, ...)
+{
+  int result;
+  va_list ap;
+  va_start (ap, format);
+  result = _IO_obstack_vprintf (obstack, format, ap);
+  va_end (ap);
+  return result;
+}
+#ifdef weak_alias
+weak_alias (_IO_obstack_printf, obstack_printf)
+#endif
diff --git a/libio/stdio/vasprintf.c b/libio/stdio/vasprintf.c
new file mode 100644 (file)
index 0000000..15513d0
--- /dev/null
@@ -0,0 +1,72 @@
+/* Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU IO Library.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This library is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this library; see the file COPYING.  If not, write to
+   the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+   As a special exception, if you link this library with files
+   compiled with a GNU compiler to produce an executable, this does
+   not cause the resulting executable to be covered by the GNU General
+   Public License.  This exception does not however invalidate any
+   other reasons why the executable file might be covered by the GNU
+   General Public License.  */
+
+#include <malloc.h>
+#include "libioP.h"
+#include "stdio.h"
+#include "strfile.h"
+
+int
+_IO_vasprintf (result_ptr, format, args)
+     char **result_ptr;
+     const char *format;
+     _IO_va_list args;
+{
+  /* Initial size of the buffer to be used.  Will be doubled each time an
+     overflow occurs.  */
+  const _IO_size_t init_string_size = 100;
+  char *string;
+  _IO_strfile sf;
+#ifdef _IO_MTSAFE_IO
+  _IO_lock_t lock;
+#endif
+  int ret;
+  string = (char *) malloc (init_string_size);
+  if (string == NULL)
+    return -1;
+#ifdef _IO_MTSAFE_IO
+  sf._sbf._f._lock = &lock;
+#endif
+  _IO_init ((_IO_FILE *) &sf, 0);
+  _IO_JUMPS ((_IO_FILE *) &sf) = &_IO_str_jumps;
+  _IO_str_init_static ((_IO_FILE *) &sf, string, init_string_size, string);
+  sf._sbf._f._flags &= ~_IO_USER_BUF;
+  sf._s._allocate_buffer = (_IO_alloc_type) malloc;
+  sf._s._free_buffer = (_IO_free_type) free;
+  ret = _IO_vfprintf ((_IO_FILE *) &sf, format, args);
+  if (ret < 0)
+    return ret;
+  *result_ptr = (char *) realloc (sf._sbf._f._IO_buf_base,
+                                 (sf._sbf._f._IO_write_ptr
+                                  - sf._sbf._f._IO_write_base) +1);
+  if (*result_ptr == NULL)
+    *result_ptr = sf._sbf._f._IO_buf_base;
+  (*result_ptr)[sf._sbf._f._IO_write_ptr-sf._sbf._f._IO_write_base] = '\0';
+  return ret;
+}
+
+#ifdef weak_alias
+weak_alias (_IO_vasprintf, vasprintf)
+#endif
diff --git a/libstdc++/config/linux.mt b/libstdc++/config/linux.mt
new file mode 100644 (file)
index 0000000..6afe1e5
--- /dev/null
@@ -0,0 +1 @@
+MT_CFLAGS = -D_PTHREADS
This page took 0.072821 seconds and 5 git commands to generate.