Changeset 16da5f8e in mainline


Ignore:
Timestamp:
2009-03-02T21:18:15Z (16 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
20f1597
Parents:
8dc72b64
Message:

String functions should be declared in string.h (and implemented in string.c) in the kernel.

Location:
kernel
Files:
2 added
20 edited

Legend:

Unmodified
Added
Removed
  • kernel/Makefile

    r8dc72b64 r16da5f8e  
    186186        generic/src/lib/memstr.c \
    187187        generic/src/lib/sort.c \
     188        generic/src/lib/string.c \
    188189        generic/src/lib/elf.c \
    189190        generic/src/lib/rd.c \
  • kernel/arch/ia32/src/boot/cboot.c

    r8dc72b64 r16da5f8e  
    3939#include <config.h>
    4040#include <memstr.h>
    41 #include <func.h>
     41#include <string.h>
    4242
    4343/* This is a symbol so the type is only dummy. Obtain the value using &. */
  • kernel/arch/sparc64/src/console.c

    r8dc72b64 r16da5f8e  
    5757#include <arch.h>
    5858#include <panic.h>
    59 #include <func.h>
     59#include <string.h>
    6060#include <print.h>
    6161
  • kernel/arch/sparc64/src/drivers/kbd.c

    r8dc72b64 r16da5f8e  
    4646#include <arch/types.h>
    4747#include <align.h>
    48 #include <func.h>
     48#include <string.h>
    4949#include <print.h>
    5050#include <sysinfo/sysinfo.h>
  • kernel/arch/sparc64/src/drivers/pci.c

    r8dc72b64 r16da5f8e  
    4343#include <debug.h>
    4444#include <print.h>
    45 #include <func.h>
     45#include <string.h>
    4646#include <arch/asm.h>
    4747#include <sysinfo/sysinfo.h>
  • kernel/arch/sparc64/src/drivers/scr.c

    r8dc72b64 r16da5f8e  
    3838#include <genarch/fb/visuals.h>
    3939#include <arch/types.h>
    40 #include <func.h>
     40#include <string.h>
    4141#include <align.h>
    4242#include <print.h>
  • kernel/arch/sparc64/src/drivers/sgcn.c

    r8dc72b64 r16da5f8e  
    3939#include <genarch/ofw/ofw_tree.h>
    4040#include <debug.h>
    41 #include <func.h>
     41#include <string.h>
    4242#include <print.h>
    4343#include <mm/page.h>
  • kernel/genarch/src/ofw/ebus.c

    r8dc72b64 r16da5f8e  
    3939#include <arch/memstr.h>
    4040#include <arch/trap/interrupt.h>
    41 #include <func.h>
     41#include <string.h>
    4242#include <panic.h>
    4343#include <debug.h>
  • kernel/genarch/src/ofw/fhc.c

    r8dc72b64 r16da5f8e  
    3939#include <arch/drivers/fhc.h>
    4040#include <arch/memstr.h>
    41 #include <func.h>
     41#include <string.h>
    4242#include <panic.h>
    4343#include <macros.h>
  • kernel/genarch/src/ofw/ofw_tree.c

    r8dc72b64 r16da5f8e  
    3939#include <arch/memstr.h>
    4040#include <mm/slab.h>
    41 #include <func.h>
     41#include <string.h>
    4242#include <print.h>
    4343#include <panic.h>
  • kernel/genarch/src/ofw/pci.c

    r8dc72b64 r16da5f8e  
    4040#include <arch/trap/interrupt.h>
    4141#include <arch/memstr.h>
    42 #include <func.h>
     42#include <string.h>
    4343#include <panic.h>
    4444#include <macros.h>
  • kernel/generic/include/func.h

    r8dc72b64 r16da5f8e  
    4242
    4343extern void halt(void);
    44 
    45 extern size_t strlen(const char *str);
    46 extern int strcmp(const char *src, const char *dst);
    47 extern int strncmp(const char *src, const char *dst, size_t len);
    48 extern void strncpy(char *dest, const char *src, size_t len);
    4944extern unative_t atoi(const char *text);
    5045extern void order(const uint64_t val, uint64_t *rv, char *suffix);
  • kernel/generic/include/memstr.h

    r8dc72b64 r16da5f8e  
    4747extern void *memmove(void *dst, const void *src, size_t cnt);
    4848
    49 extern char *strcpy(char *dest, const char *src);
    50 
    5149#endif
    5250
  • kernel/generic/src/console/cmd.c

    r8dc72b64 r16da5f8e  
    5151#include <config.h>
    5252#include <func.h>
     53#include <string.h>
    5354#include <macros.h>
    5455#include <debug.h>
  • kernel/generic/src/console/kconsole.c

    r8dc72b64 r16da5f8e  
    5050#include <debug.h>
    5151#include <func.h>
     52#include <string.h>
    5253#include <symtab.h>
    5354#include <macros.h>
  • kernel/generic/src/debug/symtab.c

    r8dc72b64 r16da5f8e  
    3838#include <symtab.h>
    3939#include <byteorder.h>
    40 #include <func.h>
     40#include <string.h>
    4141#include <print.h>
    4242#include <arch/types.h>
  • kernel/generic/src/lib/func.c

    r8dc72b64 r16da5f8e  
    7878}
    7979
    80 /** Return number of characters in a string.
    81  *
    82  * @param str NULL terminated string.
    83  *
    84  * @return Number of characters in str.
    85  */
    86 size_t strlen(const char *str)
    87 {
    88         int i;
    89        
    90         for (i = 0; str[i]; i++)
    91                 ;
    92        
    93         return i;
    94 }
    95 
    96 /** Compare two NULL terminated strings
    97  *
    98  * Do a char-by-char comparison of two NULL terminated strings.
    99  * The strings are considered equal iff they consist of the same
    100  * characters on the minimum of their lengths.
    101  *
    102  * @param src First string to compare.
    103  * @param dst Second string to compare.
    104  *
    105  * @return 0 if the strings are equal, -1 if first is smaller, 1 if second smaller.
    106  *
    107  */
    108 int strcmp(const char *src, const char *dst)
    109 {
    110         for (; *src && *dst; src++, dst++) {
    111                 if (*src < *dst)
    112                         return -1;
    113                 if (*src > *dst)
    114                         return 1;
    115         }
    116         if (*src == *dst)
    117                 return 0;
    118         if (!*src)
    119                 return -1;
    120         return 1;
    121 }
    122 
    123 
    124 /** Compare two NULL terminated strings
    125  *
    126  * Do a char-by-char comparison of two NULL terminated strings.
    127  * The strings are considered equal iff they consist of the same
    128  * characters on the minimum of their lengths and specified maximal
    129  * length.
    130  *
    131  * @param src First string to compare.
    132  * @param dst Second string to compare.
    133  * @param len Maximal length for comparison.
    134  *
    135  * @return 0 if the strings are equal, -1 if first is smaller, 1 if second smaller.
    136  *
    137  */
    138 int strncmp(const char *src, const char *dst, size_t len)
    139 {
    140         unsigned int i;
    141        
    142         for (i = 0; (*src) && (*dst) && (i < len); src++, dst++, i++) {
    143                 if (*src < *dst)
    144                         return -1;
    145                 if (*src > *dst)
    146                         return 1;
    147         }
    148         if (i == len || *src == *dst)
    149                 return 0;
    150         if (!*src)
    151                 return -1;
    152         return 1;
    153 }
    154 
    155 
    156 
    157 /** Copy NULL terminated string.
    158  *
    159  * Copy at most 'len' characters from string 'src' to 'dest'.
    160  * If 'src' is shorter than 'len', '\0' is inserted behind the
    161  * last copied character.
    162  *
    163  * @param src Source string.
    164  * @param dest Destination buffer.
    165  * @param len Size of destination buffer.
    166  */
    167 void strncpy(char *dest, const char *src, size_t len)
    168 {
    169         unsigned int i;
    170         for (i = 0; i < len; i++) {
    171                 if (!(dest[i] = src[i]))
    172                         return;
    173         }
    174         dest[i-1] = '\0';
    175 }
    176 
    17780/** Convert ascii representation to unative_t
    17881 *
  • kernel/generic/src/lib/memstr.c

    r8dc72b64 r16da5f8e  
    161161}
    162162
    163 /** Copy string.
    164  *
    165  * Copy string from src address to dst address.  The copying is done
    166  * char-by-char until the null character. The source and destination memory
    167  * areas cannot overlap.
    168  *
    169  * @param src           Source string to copy from.
    170  * @param dst           Destination string to copy to.
    171  *
    172  * @return              Address of the destination string.
    173  */
    174 char *strcpy(char *dest, const char *src)
    175 {
    176         char *orig = dest;
    177        
    178         while ((*(dest++) = *(src++)))
    179                 ;
    180         return orig;
    181 }
    182 
    183163/** @}
    184164 */
  • kernel/generic/src/printf/printf_core.c

    r8dc72b64 r16da5f8e  
    4141#include <arch/arg.h>
    4242#include <macros.h>
    43 #include <func.h>
     43#include <string.h>
    4444#include <arch.h>
    4545
  • kernel/generic/src/proc/task.c

    r8dc72b64 r16da5f8e  
    5353#include <errno.h>
    5454#include <func.h>
     55#include <string.h>
    5556#include <syscall/copy.h>
    5657
Note: See TracChangeset for help on using the changeset viewer.