fslongjin 3 лет назад
Родитель
Сommit
2467367e05
1 измененных файлов с 32 добавлено и 0 удалено
  1. 32 0
      kernel/common/glib.h

+ 32 - 0
kernel/common/glib.h

@@ -231,6 +231,38 @@ void *memcpy(void *dst, void *src, long Num)
                          : "memory");
     return dst;
 }
+
+/*
+		比较字符串 FirstPart and SecondPart
+		FirstPart = SecondPart =>  0
+		FirstPart > SecondPart =>  1
+		FirstPart < SecondPart => -1
+*/
+
+int strcmp(char * FirstPart,char * SecondPart)
+{
+	register int __res;
+	__asm__	__volatile__	(	"cld	\n\t"
+					"1:	\n\t"
+					"lodsb	\n\t"
+					"scasb	\n\t"
+					"jne	2f	\n\t"
+					"testb	%%al,	%%al	\n\t"
+					"jne	1b	\n\t"
+					"xorl	%%eax,	%%eax	\n\t"
+					"jmp	3f	\n\t"
+					"2:	\n\t"
+					"movl	$1,	%%eax	\n\t"
+					"jl	3f	\n\t"
+					"negl	%%eax	\n\t"
+					"3:	\n\t"
+					:"=a"(__res)
+					:"D"(FirstPart),"S"(SecondPart)
+					:					
+				);
+	return __res;
+}
+
 void *memset_c(void *dst, unsigned char c, ul n)
 {
     unsigned char *s = (unsigned char *)dst;