0001-libc-Add-assembler-ffs-fls-ffsl-flsl.patch

vsrinivas, 06/04/2010 07:01 PM

Download (12.9 KB)

View differences:

lib/libc/i386/string/Makefile.inc
2 2
# $FreeBSD: src/lib/libc/i386/string/Makefile.inc,v 1.9 1999/08/27 23:59:29 peter Exp $
3 3
# $DragonFly: src/lib/libc/i386/string/Makefile.inc,v 1.2 2003/06/17 04:26:43 dillon Exp $
4 4

  
5
MDSRCS+=bcmp.S bcopy.S bzero.S ffs.S index.S memchr.S memcmp.S memcpy.S \
6
	memmove.S memset.S rindex.S strcat.S strchr.S strcmp.S strcpy.S \
7
	strlen.S strncmp.S strrchr.S swab.S
5
MDSRCS+=bcmp.S bcopy.S bzero.S ffs.S ffsl.S fls.S flsl.S index.S memchr.S \
6
	memcmp.S memcpy.S memmove.S memset.S rindex.S strcat.S strchr.S \
7
	strcmp.S strcpy.S strlen.S strncmp.S strrchr.S swab.S
lib/libc/i386/string/ffs.S
44 44
 *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
45 45
 */
46 46

  
47
#ifdef FFSL
48
ENTRY(ffsl)
49
#else
47 50
ENTRY(ffs)
51
#endif
48 52
	bsfl	4(%esp),%eax
49 53
	jz	L1	 		/* ZF is set if all bits are 0 */
50 54
	incl	%eax			/* bits numbered from 1, not 0 */
lib/libc/i386/string/ffsl.S
1
#define FFSL
2
#include "ffs.S"
lib/libc/i386/string/fls.S
1
/*
2
 * Copyright (c) 2010 The DragonFly Project
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 * 3. The name of the author may not be used to endorse or promote products
14
 *    derived from this software withough specific prior written permission
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 */
27

  
28
#include "DEFS.h"
29

  
30
/*
31
 * fls(value)
32
 * 	Finds the highest set bit in a word. Bits are numbered from 1;
33
 *	a return of 0 indicates that the word was 0.
34
 */
35
#ifdef FLSL
36
ENTRY(flsl)
37
#else
38
ENTRY(fls)
39
#endif
40
	bsrl	4(%esp),%eax
41
	jz	L1
42
	addl	$1,%eax
43
	ret
44

  
45
L1:	xorl	%eax, %eax
46
	ret
lib/libc/i386/string/flsl.S
1
#define FLSL
2
#include "fls.S"
lib/libc/x86_64/string/Makefile.inc
1 1
# $FreeBSD: src/lib/libc/amd64/string/Makefile.inc,v 1.5 2005/04/10 18:58:49 alc Exp $
2 2

  
3
MDSRCS+= bcmp.S bcopy.S bzero.S memcmp.S memcpy.S memmove.S memset.S \
4
	strcat.S strcmp.S strcpy.S
3
MDSRCS+= bcmp.S bcopy.S bzero.S ffs.S ffsl.S fls.S flsl.S memcmp.S memcpy.S \
4
	memmove.S memset.S strcat.S strcmp.S strcpy.S 
lib/libc/x86_64/string/ffs.S
1
/*
2
 * Copyright (c) 2010 The DragonFly Project
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 * 3. The name of the author may not be used to endorse or promote products
14
 *    derived from this software withough specific prior written permission
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 */
27

  
28
#include <machine/asm.h>
29

  
30
/*
31
 * ffs(value)
32
 * 	Finds the lowest set bit in a word. Bits are numbered from 1;
33
 *	a return of 0 indicates that the word was 0.
34
 */
35
ENTRY(ffs)
36
	movl	$-1, %ecx
37
	bsfl	%edi,%eax
38
	cmovzl	%ecx, %eax
39
	addl	$1, %eax
40
	ret
lib/libc/x86_64/string/ffsl.S
1
/*
2
 * Copyright (c) 2010 The DragonFly Project
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 * 3. The name of the author may not be used to endorse or promote products
14
 *    derived from this software withough specific prior written permission
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 */
27

  
28
#include <machine/asm.h>
29

  
30
/*
31
 * ffsl(value)
32
 * 	Finds the highest set bit in a word. Bits are numbered from 1;
33
 *	a return of 0 indicates that the word was 0.
34
 */
35
ENTRY(ffsl)
36
	movq	$-1, %rcx
37
	bsfq	%rdi,%rax
38
	cmovzq	%rcx, %rax
39
	addq	$1, %rax
40
	ret
lib/libc/x86_64/string/fls.S
1
/*
2
 * Copyright (c) 2010 The DragonFly Project
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 * 3. The name of the author may not be used to endorse or promote products
14
 *    derived from this software withough specific prior written permission
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 */
27

  
28
#include <machine/asm.h>
29

  
30
/*
31
 * fls(value)
32
 * 	Finds the highest set bit in a word. Bits are numbered from 1;
33
 *	a return of 0 indicates that the word was 0.
34
 */
35
ENTRY(fls)
36
	movl	$-1, %ecx
37
	bsrl	%edi,%eax
38
	cmovzl	%ecx, %eax
39
	addl	$1, %eax
40
	ret
lib/libc/x86_64/string/flsl.S
1
/*
2
 * Copyright (c) 2010 The DragonFly Project
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 * 3. The name of the author may not be used to endorse or promote products
14
 *    derived from this software withough specific prior written permission
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 */
27

  
28
#include <machine/asm.h>
29

  
30
/*
31
 * flsl(value)
32
 * 	Finds the highest set bit in a word. Bits are numbered from 1;
33
 *	a return of 0 indicates that the word was 0.
34
 */
35
ENTRY(flsl)
36
	movq	$-1, %rcx
37
	bsrq	%rdi,%rax
38
	cmovzq	%rcx, %rax
39
	addq	$1, %rax
40
	ret
0
-