evil: remove useless code

This commit is contained in:
Vincent Torri 2018-01-03 06:17:35 +01:00 committed by Cedric BAIL
parent 9b2c0d0988
commit 7af3ad2160
5 changed files with 0 additions and 466 deletions

View File

@ -15,7 +15,6 @@
#include "evil_test_environment.h"
#include "evil_test_gettimeofday.h"
#include "evil_test_link.h"
#include "evil_test_memcpy.h"
#include "evil_test_mkstemp.h"
#include "evil_test_pipe.h"
#include "evil_test_print.h"

View File

@ -1,145 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <stdlib.h>
#include <stdio.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#include "evil_suite.h"
#include "evil_test_memcpy.h"
typedef void *(*memcpy_decl)(void *dest, const void *src, size_t n);
void *memcpy_glibc(void *dest, const void *src, size_t n);
static unsigned char *buf1 = NULL;
static unsigned char *buf2 = NULL;
static size_t page_size = 0;
#if defined (__MINGW32CE__) || defined (_MSC_VER)
static int
getpagesize()
{
return 1024;
}
#endif /* __MINGW32CE__ || _MSC_VER */
static void
test_memcpy_test_run(suite *s, memcpy_decl fct, char *dst, const char *src, size_t len)
{
double best;
int i;
best = 1000000000.0;
for (i = 0; i < 128; ++i)
{
double time;
suite_time_start(s);
fct(dst, src, len);
suite_time_stop(s);
time = suite_time_get(s);
if (time < best) best = time;
}
printf (" %e", best);
}
static void
test_memcpy_tests_run(suite *s, size_t align1, size_t align2, size_t len)
{
size_t i, j;
char *s1, *s2;
printf ("running test..\n");
/* align1 &= 63; */
/* if (align1 + len >= page_size) */
/* return; */
/* align2 &= 63; */
/* if (align2 + len >= page_size) */
/* return; */
s1 = (char *) (buf1 + align1);
s2 = (char *) (buf2 + align2);
for (i = 0, j = 1; i < len; i++, j += 23)
s1[i] = j;
printf ("length: %6d, align %2Iu/%2Iu:", (int)len, align1, align2);
test_memcpy_test_run(s, memcpy, s2, s1, len);
#ifdef _WIN32_WCE
test_memcpy_test_run(s, memcpy_glibc, s2, s1, len);
#endif /* _WIN32_WCE */
printf ("\n");
}
int
test_memcpy(suite *s)
{
size_t i;
page_size = 2 * 1024;
buf1 = (unsigned char *)malloc(16 * getpagesize());
if (!buf1) return 0;
buf2 = (unsigned char *)malloc(16 * getpagesize());
if (!buf2)
{
free(buf1);
return 0;
}
memset (buf1, 0xa5, page_size);
memset (buf2, 0x5a, page_size);
for (i = 0; i < 5; ++i)
{
test_memcpy_tests_run(s, 0, 0, 1 << i);
test_memcpy_tests_run(s, i, 0, 1 << i);
test_memcpy_tests_run(s, 0, i, 1 << i);
test_memcpy_tests_run(s, i, i, 1 << i);
}
for (i = 0; i < 32; ++i)
{
test_memcpy_tests_run(s, 0, 0, i);
test_memcpy_tests_run(s, i, 0, i);
test_memcpy_tests_run(s, 0, i, i);
test_memcpy_tests_run(s, i, i, i);
}
for (i = 3; i < 32; ++i)
{
if ((i & (i - 1)) == 0)
continue;
test_memcpy_tests_run(s, 0, 0, 16 * i);
test_memcpy_tests_run(s, i, 0, 16 * i);
test_memcpy_tests_run(s, 0, i, 16 * i);
test_memcpy_tests_run(s, i, i, 16 * i);
}
test_memcpy_tests_run(s, 0, 0, getpagesize ());
test_memcpy_tests_run(s, 0, 0, 2 * getpagesize ());
test_memcpy_tests_run(s, 0, 0, 4 * getpagesize ());
test_memcpy_tests_run(s, 0, 0, 8 * getpagesize ());
test_memcpy_tests_run(s, 0, 0, 16 * getpagesize ());
free(buf2);
free(buf1);
return 1;
}

View File

@ -1,8 +0,0 @@
#ifndef __EVIL_TEST_MEMCPY__
#define __EVIL_TEST_MEMCPY__
int test_memcpy(suite *s);
#endif /* __EVIL_TEST_MEMCPY__ */

View File

@ -1,231 +0,0 @@
/* Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by MontaVista Software, Inc. (written by Nicolas Pitre)
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
/* Copyright (C) 2008 Vincent Torri
modification of the name and of the entry / end declaration
*/
/*
* Data preload for architectures that support it (ARM V5TE and above)
*/
#if (!defined (__ARM_ARCH_2__) && !defined (__ARM_ARCH_3__) \
&& !defined (__ARM_ARCH_3M__) && !defined (__ARM_ARCH_4__) \
&& !defined (__ARM_ARCH_4T__) && !defined (__ARM_ARCH_5__) \
&& !defined (__ARM_ARCH_5T__))
#define PLD(code...) code
#else
#define PLD(code...)
#endif
/*
* This can be used to enable code to cacheline align the source pointer.
* Experiments on tested architectures (StrongARM and XScale) didn't show
* this a worthwhile thing to do. That might be different in the future.
*/
//#define CALGN(code...) code
#define CALGN(code...)
/*
* Endian independent macros for shifting bytes within registers.
*/
#ifndef __ARMEB__
#define pull lsr
#define push lsl
#else
#define pull lsl
#define push lsr
#endif
.text
/* Prototype: void *memcpy_glibc(void *dest, const void *src, size_t n); */
.align
.global memcpy_glibc
.func memcpy_glibc
memcpy_glibc:
stmfd sp!, {r0, r4, lr}
subs r2, r2, #4
blt 8f
ands ip, r0, #3
PLD( pld [r1, #0] )
bne 9f
ands ip, r1, #3
bne 10f
1: subs r2, r2, #(28)
stmfd sp!, {r5 - r8}
blt 5f
CALGN( ands ip, r1, #31 )
CALGN( rsb r3, ip, #32 )
CALGN( sbcnes r4, r3, r2 ) @ C is always set here
CALGN( bcs 2f )
CALGN( adr r4, 6f )
CALGN( subs r2, r2, r3 ) @ C gets set
CALGN( add pc, r4, ip )
PLD( pld [r1, #0] )
2: PLD( subs r2, r2, #96 )
PLD( pld [r1, #28] )
PLD( blt 4f )
PLD( pld [r1, #60] )
PLD( pld [r1, #92] )
3: PLD( pld [r1, #124] )
4: ldmia r1!, {r3, r4, r5, r6, r7, r8, ip, lr}
subs r2, r2, #32
stmia r0!, {r3, r4, r5, r6, r7, r8, ip, lr}
bge 3b
PLD( cmn r2, #96 )
PLD( bge 4b )
5: ands ip, r2, #28
rsb ip, ip, #32
addne pc, pc, ip @ C is always clear here
b 7f
6: nop
ldr r3, [r1], #4
ldr r4, [r1], #4
ldr r5, [r1], #4
ldr r6, [r1], #4
ldr r7, [r1], #4
ldr r8, [r1], #4
ldr lr, [r1], #4
add pc, pc, ip
nop
nop
str r3, [r0], #4
str r4, [r0], #4
str r5, [r0], #4
str r6, [r0], #4
str r7, [r0], #4
str r8, [r0], #4
str lr, [r0], #4
CALGN( bcs 2b )
7: ldmfd sp!, {r5 - r8}
8: movs r2, r2, lsl #31
ldrneb r3, [r1], #1
ldrcsb r4, [r1], #1
ldrcsb ip, [r1]
strneb r3, [r0], #1
strcsb r4, [r0], #1
strcsb ip, [r0]
ldmfd sp!, {r0, r4, pc}
9: rsb ip, ip, #4
cmp ip, #2
ldrgtb r3, [r1], #1
ldrgeb r4, [r1], #1
ldrb lr, [r1], #1
strgtb r3, [r0], #1
strgeb r4, [r0], #1
subs r2, r2, ip
strb lr, [r0], #1
blt 8b
ands ip, r1, #3
beq 1b
10: bic r1, r1, #3
cmp ip, #2
ldr lr, [r1], #4
beq 17f
bgt 18f
.macro forward_copy_shift pull push
subs r2, r2, #28
blt 14f
CALGN( ands ip, r1, #31 )
CALGN( rsb ip, ip, #32 )
CALGN( sbcnes r4, ip, r2 ) @ C is always set here
CALGN( subcc r2, r2, ip )
CALGN( bcc 15f )
11: stmfd sp!, {r5 - r9}
PLD( pld [r1, #0] )
PLD( subs r2, r2, #96 )
PLD( pld [r1, #28] )
PLD( blt 13f )
PLD( pld [r1, #60] )
PLD( pld [r1, #92] )
12: PLD( pld [r1, #124] )
13: ldmia r1!, {r4, r5, r6, r7}
mov r3, lr, pull #\pull
subs r2, r2, #32
ldmia r1!, {r8, r9, ip, lr}
orr r3, r3, r4, push #\push
mov r4, r4, pull #\pull
orr r4, r4, r5, push #\push
mov r5, r5, pull #\pull
orr r5, r5, r6, push #\push
mov r6, r6, pull #\pull
orr r6, r6, r7, push #\push
mov r7, r7, pull #\pull
orr r7, r7, r8, push #\push
mov r8, r8, pull #\pull
orr r8, r8, r9, push #\push
mov r9, r9, pull #\pull
orr r9, r9, ip, push #\push
mov ip, ip, pull #\pull
orr ip, ip, lr, push #\push
stmia r0!, {r3, r4, r5, r6, r7, r8, r9, ip}
bge 12b
PLD( cmn r2, #96 )
PLD( bge 13b )
ldmfd sp!, {r5 - r9}
14: ands ip, r2, #28
beq 16f
15: mov r3, lr, pull #\pull
ldr lr, [r1], #4
subs ip, ip, #4
orr r3, r3, lr, push #\push
str r3, [r0], #4
bgt 15b
CALGN( cmp r2, #0 )
CALGN( bge 11b )
16: sub r1, r1, #(\push / 8)
b 8b
.endm
forward_copy_shift pull=8 push=24
17: forward_copy_shift pull=16 push=16
18: forward_copy_shift pull=24 push=8
.endfunc

View File

@ -1,81 +0,0 @@
/* Copy memory block and return pointer to beginning of destination block
For Intel 80x86, x>=6.
This file is part of the GNU C Library.
Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
# define CHECK_BOUNDS_BOTH_WIDE(VAL_REG, BP_MEM, LENGTH) \
CHECK_BOUNDS_LOW(VAL_REG, BP_MEM); \
addl LENGTH, VAL_REG; \
cmpl 8+BP_MEM, VAL_REG; \
jbe 0f; /* continue if value <= high */ \
BOUNDS_VIOLATED; \
0: subl LENGTH, VAL_REG /* restore value */
# define RETURN_BOUNDED_POINTER(BP_MEM) \
movl RTN(%esp), %edx; \
movl %eax, 0(%edx); \
movl 4+BP_MEM, %eax; \
movl %eax, 4(%edx); \
movl 8+BP_MEM, %eax; \
movl %eax, 8(%edx)
#define PTR_SIZE 12
#define RTN_SIZE 4
#define LINKAGE 8
#define PARMS LINKAGE /* no space for saved regs */
#define RTN PARMS
#define DEST RTN+RTN_SIZE
#define SRC DEST+PTR_SIZE
#define LEN SRC+PTR_SIZE
.text
.align
.global memcpy_glibc
.func memcpy_glibc
memcpy_glibc:
pushl %ebp
movl %esp, %ebp
movl LEN(%esp), %ecx
movl %edi, %eax
movl DEST(%esp), %edi
movl %esi, %edx
movl SRC(%esp), %esi
cld
shrl $1, %ecx
jnc 1f
movsb
1: shrl $1, %ecx
jnc 2f
movsw
2: rep
movsl
movl %eax, %edi
movl %edx, %esi
movl DEST(%esp), %eax
RETURN_BOUNDED_POINTER (DEST(%esp))
movl %ebp, %esp
popl %ebp
.endfunc