Skip to content

Commit

Permalink
add strcpy
Browse files Browse the repository at this point in the history
Omar002 committed Mar 11, 2014
1 parent 5aca5b2 commit 41c7881
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -41,7 +41,8 @@ main.bin: kernel.c context_switch.s syscall.s syscall.h
syscall.s \
stm32_p103.c \
kernel.c \
memcpy.s
memcpy.s \
unit_test.c
$(CROSS_COMPILE)objcopy -Obinary main.elf main.bin
$(CROSS_COMPILE)objdump -S main.elf > main.list

@@ -130,4 +131,4 @@ check: unit_test.c unit_test.h
@pkill -9 $(notdir $(QEMU_STM32))

clean:
rm -f *.elf *.bin *.list
rm -f *.elf *.bin *.list *.txt
11 changes: 10 additions & 1 deletion kernel.c
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
#include "RTOSConfig.h"
#include "core_cm3.h"
#include "syscall.h"
#include <stddef.h>
#include "kernel.h"

void *malloc(size_t size)
@@ -39,6 +38,16 @@ int strncmp(const char *a, const char *b, size_t n)
return 0;
}


char *strcpy(char *s1, const char *s2) __attribute__ ((naked));
char *strcpy(char *s1, const char *s2)

This comment has been minimized.

Copy link
@jserv

jserv Mar 11, 2014

You can add the assembly version of strcpy as well. Thus, you can perform unit testing to verify the implementation.

{
char *s = s1;
while( (*s++ = *s2++) !=0)
;
return (s1);
}

size_t strlen(const char *s) __attribute__ ((naked));
size_t strlen(const char *s)
{
2 changes: 2 additions & 0 deletions kernel.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef KERNEL_H
#define KERNEL_H

#include <stddef.h>

#define MAX_CMDNAME 19
#define MAX_ARGC 19
#define MAX_CMDHELP 1023

0 comments on commit 41c7881

Please sign in to comment.