avr-libc-commit
[Top][All Lists]
Advanced

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

[avr-libc-commit] [2427] libstdc++-v3 support:


From: Joern Rennecke
Subject: [avr-libc-commit] [2427] libstdc++-v3 support:
Date: Thu, 01 May 2014 14:06:03 +0000

Revision: 2427
          http://svn.sv.gnu.org/viewvc/?view=rev&root=avr-libc&revision=2427
Author:   amylaar
Date:     2014-05-01 14:06:03 +0000 (Thu, 01 May 2014)
Log Message:
-----------
libstdc++-v3 support:
        * configure.ac (AC_CONFIG_FILES): Add include/sys/Makefile.
        * include/Makefile.am (avr_HEADERS): Add fcntl.h, locale.h, unistd.h.
        (SUBDIRS): Add sys.
        * include/errno.h: Add definitions for error codes required to compile
        libstdc++-v3.
        * include/locale.h, include/unistd.h, include/fcntl.h: New files.
        * include/stdio.h (FILE): Change to a typedef.
        (BUFSIZ, _IONBF): Define.
        (fpos_t): Typedef.
        (fgetpos, fopen, freopen, fdopen, fseek, fsetpos, ftell): Prototype.
        (ftell, fileno, perror, remote, rename, rewind, setbuf): Likewise.
        (setvbuf, tmpfile, tmpnam): Likewise.
        * include/stdlib.h (atexit, system, getenv): Prototype.
        * include/string.h (strcoll, strerror, strxfrm): Prototype.
        * include/sys: New directory.
        * include/time.h (_CLOCKS_PER_SEC_): Declare.
        (CLOCKS_PER_SEC): Define.
        (clock): Declare.
        * libc/stdlib/Files.am (stdlib_a_c_sources): Add atexit.c, getenv.c,
        system.c
        * libc/stdlib/atexit.c: New file.
        * libc/stdlib/getenv.c, * libc/stdlib/system.c: New stub files.

This provides a bit of functionality, but mostly stubs, for hosted features
that we've been missing.  The alternative would be to make avr an outright
unhosted target, but that'd make it harder to test, and would also stop
using some applications that depend on minimal hosted features.

Modified Paths:
--------------
    trunk/avr-libc/ChangeLog
    trunk/avr-libc/configure.ac
    trunk/avr-libc/include/Makefile.am
    trunk/avr-libc/include/errno.h
    trunk/avr-libc/include/stdio.h
    trunk/avr-libc/include/stdlib.h
    trunk/avr-libc/include/string.h
    trunk/avr-libc/include/time.h
    trunk/avr-libc/libc/stdlib/Files.am

Added Paths:
-----------
    trunk/avr-libc/include/fcntl.h
    trunk/avr-libc/include/locale.h
    trunk/avr-libc/include/sys/
    trunk/avr-libc/include/sys/Makefile.am
    trunk/avr-libc/include/sys/types.h
    trunk/avr-libc/include/unistd.h
    trunk/avr-libc/libc/stdlib/atexit.c
    trunk/avr-libc/libc/stdlib/getenv.c
    trunk/avr-libc/libc/stdlib/system.c

Modified: trunk/avr-libc/ChangeLog
===================================================================
--- trunk/avr-libc/ChangeLog    2014-05-01 12:49:30 UTC (rev 2426)
+++ trunk/avr-libc/ChangeLog    2014-05-01 14:06:03 UTC (rev 2427)
@@ -1,5 +1,30 @@
 2014-05-01  Joern Rennecke  <address@hidden>
 
+       * configure.ac (AC_CONFIG_FILES): Add include/sys/Makefile.
+       * include/Makefile.am (avr_HEADERS): Add fcntl.h, locale.h, unistd.h.
+       (SUBDIRS): Add sys.
+       * include/errno.h: Add definitions for error codes required to compile
+       libstdc++-v3.
+       * include/locale.h, include/unistd.h, include/fcntl.h: New files.
+       * include/stdio.h (FILE): Change to a typedef.
+       (BUFSIZ, _IONBF): Define.
+       (fpos_t): Typedef.
+       (fgetpos, fopen, freopen, fdopen, fseek, fsetpos, ftell): Prototype.
+       (ftell, fileno, perror, remote, rename, rewind, setbuf): Likewise.
+       (setvbuf, tmpfile, tmpnam): Likewise.
+       * include/stdlib.h (atexit, system, getenv): Prototype.
+       * include/string.h (strcoll, strerror, strxfrm): Prototype.
+       * include/sys: New directory.
+       * include/time.h (_CLOCKS_PER_SEC_): Declare.
+       (CLOCKS_PER_SEC): Define.
+       (clock): Declare.
+       * libc/stdlib/Files.am (stdlib_a_c_sources): Add atexit.c, getenv.c,
+       system.c
+       * libc/stdlib/atexit.c: New file.
+       * libc/stdlib/getenv.c, * libc/stdlib/system.c: New stub files.
+
+2014-05-01  Joern Rennecke  <address@hidden>
+
        * include/stdint.h [!__USING_MINT8] (UINT8_MAX): Provide (signed)
        int value.
        (SIZE_MAX): Define as UINT16_MAX.

Modified: trunk/avr-libc/configure.ac
===================================================================
--- trunk/avr-libc/configure.ac 2014-05-01 12:49:30 UTC (rev 2426)
+++ trunk/avr-libc/configure.ac 2014-05-01 14:06:03 UTC (rev 2427)
@@ -1200,6 +1200,7 @@
        include/compat/Makefile
        include/util/Makefile
        include/util/delay.h
+       include/sys/Makefile
        libc/Makefile
        libc/misc/Makefile
        libc/pmstring/Makefile

Modified: trunk/avr-libc/include/Makefile.am
===================================================================
--- trunk/avr-libc/include/Makefile.am  2014-05-01 12:49:30 UTC (rev 2426)
+++ trunk/avr-libc/include/Makefile.am  2014-05-01 14:06:03 UTC (rev 2427)
@@ -35,7 +35,9 @@
     assert.h \
     ctype.h \
     errno.h \
+    fcntl.h \
     inttypes.h \
+    locale.h \
     math.h \
     setjmp.h \
     stdfix-avrlibc.h \
@@ -43,7 +45,8 @@
     stdio.h \
     stdlib.h \
     string.h \
-    time.h
+    time.h \
+    unistd.h
 
 
-SUBDIRS = avr compat util
+SUBDIRS = avr compat util sys

Modified: trunk/avr-libc/include/errno.h
===================================================================
--- trunk/avr-libc/include/errno.h      2014-05-01 12:49:30 UTC (rev 2426)
+++ trunk/avr-libc/include/errno.h      2014-05-01 14:06:03 UTC (rev 2427)
@@ -70,4 +70,74 @@
     Range error. */
 #define ERANGE     34
 
+/* ((((('E'-64)*26+('N'-64))*26+('O'-64))*26+('S'-64))*26+('Y'-64))*26+'S'-64 
*/
+#define ENOSYS ((int)(66081697 & 0x7fff))
+
+/* (((('E'-64)*26+('I'-64))*26+('N'-64))*26+('T'-64))*26+('R'-64) */
+#define EINTR ((int)(2453066 & 0x7fff))
+
+#define E2BIG ENOERR
+#define EACCES ENOERR
+#define EADDRINUSE ENOERR
+#define EADDRNOTAVAIL ENOERR
+#define EAFNOSUPPORT ENOERR
+#define EAGAIN ENOERR
+#define EALREADY ENOERR
+#define EBADF ENOERR
+#define EBUSY ENOERR
+#define ECHILD ENOERR
+#define ECONNABORTED ENOERR
+#define ECONNREFUSED ENOERR
+#define ECONNRESET ENOERR
+#define EDEADLK ENOERR
+#define EDESTADDRREQ ENOERR
+#define EEXIST ENOERR
+#define EFAULT ENOERR
+#define EFBIG ENOERR
+#define EHOSTUNREACH ENOERR
+#define EILSEQ ENOERR
+#define EINPROGRESS ENOERR
+#define EINVAL ENOERR
+#define EIO ENOERR
+#define EISCONN ENOERR
+#define EISDIR ENOERR
+#define ELOOP ENOERR
+#define EMFILE ENOERR
+#define EMLINK ENOERR
+#define EMSGSIZE ENOERR
+#define ENAMETOOLONG ENOERR
+#define ENETDOWN ENOERR
+#define ENETRESET ENOERR
+#define ENETUNREACH ENOERR
+#define ENFILE ENOERR
+#define ENOBUFS ENOERR
+#define ENODEV ENOERR
+#define ENOENT ENOERR
+#define ENOEXEC ENOERR
+#define ENOLCK ENOERR
+#define ENOMEM ENOERR
+#define ENOMSG ENOERR
+#define ENOPROTOOPT ENOERR
+#define ENOSPC ENOERR
+#define ENOTCONN ENOERR
+#define ENOTDIR ENOERR
+#define ENOTEMPTY ENOERR
+#define ENOTSOCK ENOERR
+#define ENOTTY ENOERR
+#define ENXIO ENOERR
+#define EOPNOTSUPP ENOERR
+#define EPERM ENOERR
+#define EPIPE ENOERR
+#define EPROTONOSUPPORT ENOERR
+#define EPROTOTYPE ENOERR
+#define EROFS ENOERR
+#define ESPIPE ENOERR
+#define ESRCH ENOERR
+#define ETIMEDOUT ENOERR
+#define EWOULDBLOCK ENOERR
+#define EXDEV ENOERR
+
+/* ((((('E'-64)*26+('N'-64))*26+('O'-64))*26+('E'-64))*26+('R'-64))*26+'R'-64 
*/
+#define ENOERR ((int)(66072050 & 0xffff))
+
 #endif

Added: trunk/avr-libc/include/fcntl.h
===================================================================
--- trunk/avr-libc/include/fcntl.h                              (rev 0)
+++ trunk/avr-libc/include/fcntl.h      2014-05-01 14:06:03 UTC (rev 2427)
@@ -0,0 +1 @@
+#include <sys/types.h>

Added: trunk/avr-libc/include/locale.h
===================================================================
--- trunk/avr-libc/include/locale.h                             (rev 0)
+++ trunk/avr-libc/include/locale.h     2014-05-01 14:06:03 UTC (rev 2427)
@@ -0,0 +1,17 @@
+#ifndef _LOCALE_H
+#define _LOCALE_H
+
+#if 1 /* ??? unimplemented */
+#define LC_ALL      0
+#define LC_COLLATE  1
+#define LC_CTYPE    2
+#define LC_MESSAGES 3
+#define LC_MONETARY 4
+#define LC_NUMERIC  5
+#define LC_TIME     6
+struct lconv;
+extern char *setlocale(int category, const char *locale);
+extern struct lconv *localeconv(void);
+#endif
+
+#endif /* L_OCALE_H */

Modified: trunk/avr-libc/include/stdio.h
===================================================================
--- trunk/avr-libc/include/stdio.h      2014-05-01 12:49:30 UTC (rev 2426)
+++ trunk/avr-libc/include/stdio.h      2014-05-01 14:06:03 UTC (rev 2427)
@@ -272,7 +272,7 @@
    \c FILE is the opaque structure that is passed around between the
    various standard IO functions.
 */
-#define FILE   struct __file
+typedef struct __file FILE;
 
 /**
    Stream that will be used as an input stream by the simplified
@@ -941,6 +941,28 @@
 }
 #endif
 
+#if 1 /* ??? unimplemented  */
+#define BUFSIZ 1024
+#define _IONBF 0
+typedef long long fpos_t;
+extern int fgetpos(FILE *stream, fpos_t *pos);
+extern FILE *fopen(const char *path, const char *mode);
+extern FILE *freopen(const char *path, const char *mode, FILE *stream);
+extern FILE *fdopen(int, const char *);
+extern int fseek(FILE *stream, long offset, int whence);
+extern int fsetpos(FILE *stream, fpos_t *pos);
+extern long ftell(FILE *stream);
+extern int fileno(FILE *);
+extern void perror(const char *s);
+extern int remove(const char *pathname);
+extern int rename(const char *oldpath, const char *newpath);
+extern void rewind(FILE *stream);
+extern void setbuf(FILE *stream, char *buf);
+extern int setvbuf(FILE *stream, char *buf, int mode, size_t size);
+extern FILE *tmpfile(void);
+extern char *tmpnam (char *s);
+#endif
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/avr-libc/include/stdlib.h
===================================================================
--- trunk/avr-libc/include/stdlib.h     2014-05-01 12:49:30 UTC (rev 2426)
+++ trunk/avr-libc/include/stdlib.h     2014-05-01 14:06:03 UTC (rev 2427)
@@ -669,9 +669,9 @@
 
 /address@hidden/
 
-#if 0  /* not yet implemented */
 extern int atexit(void (*)(void));
-#endif
+extern int system (const char *);
+extern char *getenv (const char *);
 
 #ifdef __cplusplus
 }

Modified: trunk/avr-libc/include/string.h
===================================================================
--- trunk/avr-libc/include/string.h     2014-05-01 12:49:30 UTC (rev 2426)
+++ trunk/avr-libc/include/string.h     2014-05-01 14:06:03 UTC (rev 2427)
@@ -147,6 +147,12 @@
 extern char *strtok_r(char *, const char *, char **);
 extern char *strupr(char *);
 
+#if 1 /* ??? unimplemented */
+extern int strcoll(const char *s1, const char *s2);
+extern char *strerror(int errnum);
+extern size_t strxfrm(char *dest, const char *src, size_t n);
+#endif
+
 #ifdef __cplusplus
 }
 #endif

Added: trunk/avr-libc/include/sys/Makefile.am
===================================================================
--- trunk/avr-libc/include/sys/Makefile.am                              (rev 0)
+++ trunk/avr-libc/include/sys/Makefile.am      2014-05-01 14:06:03 UTC (rev 
2427)
@@ -0,0 +1,34 @@
+# Copyright (c) 2005,  Joerg Wunsch
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of the copyright holders nor the names of
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# $Id$
+#
+
+avrdir = $(prefix)/avr/include/sys
+avr_HEADERS = \
+    types.h

Added: trunk/avr-libc/include/sys/types.h
===================================================================
--- trunk/avr-libc/include/sys/types.h                          (rev 0)
+++ trunk/avr-libc/include/sys/types.h  2014-05-01 14:06:03 UTC (rev 2427)
@@ -0,0 +1,6 @@
+#ifndef _SYS_TYPES_H_
+#define _SYS_TYPES_H_ 1
+
+typedef long off_t;
+
+#endif

Modified: trunk/avr-libc/include/time.h
===================================================================
--- trunk/avr-libc/include/time.h       2014-05-01 12:49:30 UTC (rev 2426)
+++ trunk/avr-libc/include/time.h       2014-05-01 14:06:03 UTC (rev 2427)
@@ -168,6 +168,15 @@
         int16_t         tm_isdst;
     };
 
+    
+    /* We have to provide clock_t / CLOCKS_PER_SEC so that libstdc++-v3 can
+       be built.  We define CLOCKS_PER_SEC via a symbol _CLOCKS_PER_SEC_
+       so that the user can provide the value on the link line, which should
+       result in little or no run-time overhead compared with a constant.  */
+    typedef unsigned long clock_t;
+    extern char *_CLOCKS_PER_SEC_;
+#define CLOCKS_PER_SEC ((clock_t) _CLOCKS_PER_SEC_)
+    extern clock_t clock(void);
 
     /**
     This function 'compiles' the elements of a broken-down time structure, 
returning a binary time stamp.

Added: trunk/avr-libc/include/unistd.h
===================================================================
--- trunk/avr-libc/include/unistd.h                             (rev 0)
+++ trunk/avr-libc/include/unistd.h     2014-05-01 14:06:03 UTC (rev 2427)
@@ -0,0 +1,8 @@
+#define __need_size_t
+#include <stddef.h>
+
+#include <sys/types.h>
+
+extern int write (int, const void *, size_t);
+extern int read (int, void *, size_t);
+off_t lseek (int, off_t, int);

Modified: trunk/avr-libc/libc/stdlib/Files.am
===================================================================
--- trunk/avr-libc/libc/stdlib/Files.am 2014-05-01 12:49:30 UTC (rev 2426)
+++ trunk/avr-libc/libc/stdlib/Files.am 2014-05-01 14:06:03 UTC (rev 2427)
@@ -32,12 +32,14 @@
 stdlib_a_c_sources = \
        abs.c \
        assert.c \
+       atexit.c \
        bsearch.c \
        calloc.c \
        errno.c \
        dtoa_prf.c \
        dtostre.c \
        dtostrf.c \
+       getenv.c \
        labs.c \
        malloc.c \
        qsort.c \
@@ -47,6 +49,7 @@
        strtod.c \
        strtol.c \
        strtoul.c \
+       system.c \
        dtoa_conv.h \
        stdlib_private.h
 

Added: trunk/avr-libc/libc/stdlib/atexit.c
===================================================================
--- trunk/avr-libc/libc/stdlib/atexit.c                         (rev 0)
+++ trunk/avr-libc/libc/stdlib/atexit.c 2014-05-01 14:06:03 UTC (rev 2427)
@@ -0,0 +1,54 @@
+/* Copyright (c) 2013  Embecosm
+   All rights reserved.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are met:
+
+   * Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+   * Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in
+     the documentation and/or other materials provided with the
+     distribution.
+   * Neither the name of the copyright holders nor the names of
+     contributors may be used to endorse or promote products derived
+     from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+   POSSIBILITY OF SUCH DAMAGE. */
+
+#include <stdlib.h>
+
+struct atexit_s { void (*fun) (void); struct atexit_s *next; } *__atexit_p;
+
+int
+atexit (void (*fun) (void))
+{
+  struct atexit_s *new_as = (struct atexit_s *) malloc (sizeof *new_as);
+  if (!new_as)
+    return 1;
+  new_as->fun = fun;
+  new_as->next = __atexit_p;
+  __atexit_p = new_as;
+  return 0;
+}
+
+void __attribute__((section(".fini6a")))
+__atexit_fini (void)
+{
+  while (__atexit_p)
+    {
+      void (*fun) (void) = __atexit_p->fun;
+      __atexit_p = __atexit_p->next;
+      (*fun) ();
+    }
+}

Added: trunk/avr-libc/libc/stdlib/getenv.c
===================================================================
--- trunk/avr-libc/libc/stdlib/getenv.c                         (rev 0)
+++ trunk/avr-libc/libc/stdlib/getenv.c 2014-05-01 14:06:03 UTC (rev 2427)
@@ -0,0 +1,7 @@
+#include <stdlib.h>
+
+char *
+getenv (const char *name)
+{
+  return NULL;
+}

Added: trunk/avr-libc/libc/stdlib/system.c
===================================================================
--- trunk/avr-libc/libc/stdlib/system.c                         (rev 0)
+++ trunk/avr-libc/libc/stdlib/system.c 2014-05-01 14:06:03 UTC (rev 2427)
@@ -0,0 +1,11 @@
+#include <errno.h>
+#include <stdlib.h>
+
+int
+system (const char *s)
+{
+  if (s == NULL)
+    return 0;
+  errno = ENOSYS;
+  return -1;
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]