Re: [x86 setup 16/33] String-handling functions for the new x86 setup code.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jul 9 2007 19:51, H. Peter Anvin wrote:
>
>strcmp(), memcpy(), memset(), as well as routines to copy to and from
>other segments (as pointed to by fs and gs).

I wonder, strcmp() is the only one not done in assembler.
Is there a particular reason? (Or the other way around, why
is memcpy/memset not C.) The opcode is rep[n]z cmps[bl];

Would perhaps using __builtin_memset
and whatever GCC provides also work in 16-bit mode (would save
implementing it again).

>+/*
>+ * arch/i386/boot/string.c
>+ *
>+ * Very basic string functions
>+ */
>+
>+#include "boot.h"
>+#include <linux/edd.h>

What's edd good for here?

>+int strcmp(const char *str1, const char *str2)
>+{
>+	const unsigned char *s1 = (const unsigned char *)str1;
>+	const unsigned char *s2 = (const unsigned char *)str2;
>+	int delta = 0;
>+
>+	while (*s1 || *s2) {
>+		delta = *s2 - *s1;
>+		if (delta)
>+			return delta;
>+		s1++;
>+		s2++;
>+	}
>+	return 0;
>+}



	Jan
-- 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux