OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [infra/] [current/] [src/] [gccsupport.cxx] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
/*===========================================================================
2
//
3
//      gccsupport.cxx
4
//
5
//      Miscellaneous generic support functions required by GCC
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####
9
// -------------------------------------------
10
// This file is part of eCos, the Embedded Configurable Operating System.
11
// Copyright (C) 2004, 2005, 2008 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under
14
// the terms of the GNU General Public License as published by the Free
15
// Software Foundation; either version 2 or (at your option) any later
16
// version.
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21
// for more details.
22
//
23
// You should have received a copy of the GNU General Public License
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
26
//
27
// As a special exception, if other files instantiate templates or use
28
// macros or inline functions from this file, or you compile this file
29
// and link it with other works to produce a work based on this file,
30
// this file does not by itself cause the resulting work to be covered by
31
// the GNU General Public License. However the source code for this file
32
// must still be made available in accordance with section (3) of the GNU
33
// General Public License v2.
34
//
35
// This exception does not invalidate any other reasons why a work based
36
// on this file might be covered by the GNU General Public License.
37
// -------------------------------------------
38
// ####ECOSGPLCOPYRIGHTEND####
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):    jlarmour
43
// Contributors:
44
// Date:         2005-03-06
45
// Purpose:      This file provides miscellaneous support functions that have
46
//               been assumed to be present by GCC.
47
// Description:  These functions and definitions are usually defaults
48
//               for when the "real" implementation does not exist.
49
//               These are intentionally very basic implementations. Users
50
//               should pull in the real implementations from other packages
51
//               rather than these. These are purely here for GCC's
52
//               requirements and nothing more.
53
//
54
//####DESCRIPTIONEND####
55
//
56
//==========================================================================*/
57
 
58
 
59
/* INCLUDES */
60
 
61
#include <pkgconf/infra.h>      /* Configuration of infra package */
62
#include <pkgconf/isoinfra.h>   /* Configuration of isoinfra package */
63
 
64
#include <cyg/infra/cyg_type.h> /* Common type definitions */
65
    //#include <cyg/infra/cyg_trac.h> /* Tracing support */
66
    //#include <cyg/infra/cyg_ass.h>  /* Assertion support */
67
#include <stddef.h>             /* Compiler defns such as size_t, NULL etc. */
68
#include <stdio.h>
69
#include <cyg/infra/diag.h>     /* Diagnostic output */
70
 
71
/* GLOBALS */
72
 
73
 
74
#ifndef CYGINT_ISO_STDIO_FILETYPES
75
typedef long FILE;
76
#endif
77
#ifndef CYGINT_ISO_STDIO_STREAMS
78
FILE *stdout, *stderr; /* In practice, ignored */
79
#endif
80
 
81
 
82
/* FUNCTIONS */
83
#ifndef CYGINT_ISO_STDIO_CHAR_IO
84
__externC int
85
fputs( const char *string, FILE * /* ignored */ ) __THROW
86
{
87
    diag_write_string( string );
88
    return 0;
89
}
90
 
91
__externC int
92
fputc( int c, FILE * /* ignored */ ) __THROW
93
{
94
    diag_write_char( (char)c );
95
    return c;
96
}
97
 
98
#endif
99
 
100
#ifndef CYGINT_ISO_STDIO_DIRECT_IO
101
/* Recent GCC can "optimise" fputs(string, stream)
102
 * to fwrite(string, 1, len, stream).
103
 * No idea why they think that's a good idea though! */
104
__externC size_t
105
fwrite( const void *ptr, size_t object_size, size_t num_objects,
106
        FILE * /* ignored */ ) __THROW
107
{
108
    const char *str = static_cast<const char *>(ptr);
109
 
110
    /* double check GCC use before assuming. Hmm, is it possible
111
     * GCC could optimise away the terminating NULL?
112
     */
113
    if (object_size == 1 && str[num_objects] == '\0')
114
        diag_write_string( str );
115
    else
116
        return 0;
117
    return num_objects;
118
}
119
#endif
120
 
121
#ifndef CYGINT_ISO_STRING_MEMFUNCS
122
__externC int
123
memcmp( const void *s1, const void *s2, size_t n )
124
{
125
    const unsigned char *m1 = (const unsigned char *) s1;
126
    const unsigned char *m2 = (const unsigned char *) s2;
127
 
128
    while (n--)
129
    {
130
        if (*m1 != *m2)
131
        {
132
            return *m1 - *m2;
133
        }
134
        m1++;
135
        m2++;
136
    }
137
    return 0;
138
} // memcmp()
139
#endif
140
 
141
#ifndef CYGINT_ISO_STRING_STRFUNCS
142
__externC int
143
strncmp( const char *s1, const char *s2, size_t n )
144
{
145
    if (n == 0)
146
    {
147
        return 0;
148
    }
149
    while (n-- != 0 && *s1 == *s2)
150
    {
151
        if (n == 0 || *s1 == '\0' || *s2 == '\0')
152
            break;
153
        s1++;
154
        s2++;
155
    }
156
 
157
    return (*(unsigned char *) s1) - (*(unsigned char *) s2);
158
} // strncmp()
159
 
160
__externC int
161
strcmp( const char *s1, const char *s2 )
162
{
163
    // Could do simple and direct implementation, but smaller is better
164
    return strncmp( s1, s2, (size_t)-1 );
165
} // strcmp()
166
 
167
__externC char *
168
strcat( char *s1, const char *s2 )
169
{
170
    char *s = s1;
171
 
172
    while (*s1)
173
        s1++;
174
 
175
    while ((*s1++ = *s2++))
176
        ;
177
    return s;
178
} // strcat()
179
 
180
__externC char *
181
strcpy( char *s1, const char *s2 )
182
{
183
    char *s = s1;
184
 
185
    while ((*s1++ = *s2++) != '\0')
186
        ;
187
 
188
    return s;
189
} // strcpy()
190
#endif
191
 
192
 
193
/* EOF gccsupport.cxx */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.