-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2102 from ghaerr/libcasm
[kernel,libc] Various small cleanups
- Loading branch information
Showing
13 changed files
with
75 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ OBJS = \ | |
memmove.o \ | ||
memset-c.o \ | ||
fmemset-c.o \ | ||
movedata.o \ | ||
strcasecmp.o \ | ||
strcat.o \ | ||
strchr.o \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,39 @@ | ||
#include <string.h> | ||
|
||
void * | ||
memchr(const void * str, int c, size_t l) | ||
{ | ||
#ifdef BCC_ASM | ||
#asm | ||
mov bx,sp | ||
push di | ||
|
||
#ifdef PARANOID | ||
push es | ||
push ds ; Im not sure if this is needed, so just in case. | ||
pop es | ||
mov bx,sp | ||
push di | ||
push es | ||
push ds | ||
pop es | ||
cld | ||
#endif | ||
|
||
mov di,[bx+2] | ||
mov ax,[bx+4] | ||
mov cx,[bx+6] | ||
test cx,cx | ||
je is_z ! Zero length, do not find. | ||
|
||
repne ! Scan | ||
mov di,[bx+2] | ||
mov ax,[bx+4] | ||
mov cx,[bx+6] | ||
test cx,cx | ||
je is_z ! Zero length, do not find. | ||
repne ! Scan | ||
scasb | ||
jne is_z ! Not found, ret zero | ||
dec di ! Adjust ptr | ||
mov ax,di ! return | ||
jmp xit | ||
jne is_z ! Not found, ret zero | ||
dec di ! Adjust ptr | ||
mov ax,di ! return | ||
jmp xit | ||
is_z: | ||
xor ax,ax | ||
xor ax,ax | ||
xit: | ||
|
||
#ifdef PARANOID | ||
pop es | ||
pop es | ||
pop di | ||
ret | ||
#endif | ||
pop di | ||
#endasm | ||
#else /* ifdef BCC_ASM */ | ||
register unsigned char *p=(unsigned char *)str; | ||
while(l-- > 0) | ||
{ | ||
if(*p == c) return p; | ||
|
||
void * | ||
memchr(const void * str, int c, size_t l) | ||
{ | ||
unsigned char *p = (unsigned char *)str; | ||
while (l-- > 0) { | ||
if (*p == c) return p; | ||
p++; | ||
} | ||
return 0; | ||
#endif /* ifdef BCC_ASM */ | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,45 @@ | ||
#include <string.h> | ||
|
||
int | ||
strncmp(const char * d, const char * s, size_t l) | ||
{ | ||
#ifdef BCC_AX_ASM | ||
#asm | ||
mov bx,sp | ||
push si | ||
push di | ||
|
||
#ifdef PARANOID | ||
push es | ||
push ds ! Im not sure if this is needed, so just in case. | ||
pop es | ||
#ifdef BCC_ASM | ||
mov bx,sp | ||
push si | ||
push di | ||
push es | ||
push ds | ||
pop es | ||
cld | ||
#endif | ||
|
||
#if __FIRST_ARG_IN_AX__ | ||
mov si,ax | ||
mov di,[bx+2] | ||
mov cx,[bx+4] | ||
#else | ||
mov si,[bx+2] ! Fetch | ||
mov di,[bx+4] | ||
mov cx,[bx+6] | ||
#endif | ||
|
||
inc cx | ||
mov si,[bx+2] ! Fetch | ||
mov di,[bx+4] | ||
mov cx,[bx+6] | ||
inc cx | ||
lp1: | ||
dec cx | ||
je lp2 | ||
dec cx | ||
je lp2 | ||
lodsb | ||
scasb | ||
jne lp3 | ||
testb al,al | ||
jne lp1 | ||
jne lp3 | ||
testb al,al | ||
jne lp1 | ||
lp2: | ||
xor ax,ax | ||
jmp lp4 | ||
xor ax,ax | ||
jmp lp4 | ||
lp3: | ||
sbb ax,ax | ||
or al,#1 | ||
sbb ax,ax | ||
or al,#1 | ||
lp4: | ||
|
||
#ifdef PARANOID | ||
pop es | ||
pop es | ||
pop di | ||
pop si | ||
ret | ||
#endif | ||
pop di | ||
pop si | ||
#endasm | ||
#else | ||
register char c1=0, c2=0; | ||
while(l-- >0) | ||
if( (c1= *d++) != (c2= *s++) || c1 == '\0' ) | ||
|
||
int | ||
strncmp(const char * d, const char * s, size_t l) | ||
{ | ||
char c1 = 0, c2 = 0; | ||
while (l-- > 0) { | ||
if ((c1 = *d++) != (c2 = *s++) || c1 == '\0') | ||
break; | ||
return c1-c2; | ||
#endif | ||
} | ||
return c1 - c2; | ||
} |