source: soft/giet_vm/libs/string.c @ 241

Last change on this file since 241 was 241, checked in by joannou, 11 years ago
  • new application : Dhrystone
  • added new files string.c and string.h in libs to implement strcpy() and strcmp() needed by dhrystone
  • new xml mapping with 4 procs in one cluster, each one running dhrystone
File size: 1.4 KB
Line 
1//////////////////////////////////////////////////////////////////////////////////
2// File     : string.c
3// Date     : 23/05/2013
4// Author   : Alexandre JOANNOU, Laurent LAMBERT
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7
8///////////////////////////////////////////////////////////////////////////////////
9// char * strcpy ( char * destination, const char * source )
10///////////////////////////////////////////////////////////////////////////////////
11char * strcpy ( char * destination, const char * source )
12{
13    if (!destination || !source)
14        return destination;
15
16    while (*source)
17        *(destination++) = *(source++);
18
19    return destination;
20}
21
22///////////////////////////////////////////////////////////////////////////////////
23// int strcmp ( const char * str1, const char * str2 )
24///////////////////////////////////////////////////////////////////////////////////
25int strcmp ( const char * str1, const char * str2 )
26{
27    if (!str1 || !str2)
28        return -123456; // return a value out of the char's bounds
29
30    while (*str1 && *str1 == *str2)
31    {
32        str1++;
33        str2++;
34    }
35
36    return (*str1 - *str2);
37}
38
39// Local Variables:
40// tab-width: 4
41// c-basic-offset: 4
42// c-file-offsets:((innamespace . 0)(inline-open . 0))
43// indent-tabs-mode: nil
44// End:
45// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
Note: See TracBrowser for help on using the repository browser.