~ubuntu-branches/ubuntu/trusty/eglibc/trusty

« back to all changes in this revision

Viewing changes to string/test-memset.c

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2013-01-10 18:39:35 UTC
  • mfrom: (1.5.2) (4.4.24 experimental)
  • Revision ID: package-import@ubuntu.com-20130110183935-afsgfxkmg7wk5eaj
Tags: 2.17-0ubuntu1
* Merge with Debian, bringing in a new upstream and many small fixes:
  - patches/any/cvs-malloc-deadlock.diff: Dropped, merged upstream.
  - patches/ubuntu/lddebug-scopes.diff: Rebase for upstream changes.
  - patches/ubuntu/local-CVE-2012-3406.diff: Rebased against upstream.
  - patches/ubuntu/no-asm-mtune-i686.diff: Fixed in recent binutils.
* This upstream merge fixes a nasty hang in pulseaudio (LP: #1085342)
* Bump MIN_KERNEL_SUPPORTED to 2.6.32 on ARM, now that we no longer
  have to support shonky 2.6.31 kernels on imx51 babbage builders.
* Drop patches/ubuntu/local-disable-nscd-host-caching.diff, as these
  issues were apparently resolved upstream a while ago (LP: #613662)
* Fix the compiled-in bug URL to point to launchpad.net, not Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Test and measure memset functions.
2
 
   Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc.
 
2
   Copyright (C) 1999-2012 Free Software Foundation, Inc.
3
3
   This file is part of the GNU C Library.
4
4
   Written by Jakub Jelinek <jakub@redhat.com>, 1999.
5
5
 
18
18
   <http://www.gnu.org/licenses/>.  */
19
19
 
20
20
#define TEST_MAIN
 
21
#ifdef TEST_BZERO
 
22
# define TEST_NAME "bzero"
 
23
#else
 
24
# define TEST_NAME "memset"
 
25
#endif
21
26
#define MIN_PAGE_SIZE 131072
22
27
#include "test-string.h"
23
28
 
 
29
char *simple_memset (char *, int, size_t);
 
30
 
 
31
#ifdef TEST_BZERO
 
32
typedef void (*proto_t) (char *, size_t);
 
33
void simple_bzero (char *, size_t);
 
34
void builtin_bzero (char *, size_t);
 
35
 
 
36
IMPL (simple_bzero, 0)
 
37
IMPL (builtin_bzero, 0)
 
38
IMPL (bzero, 1)
 
39
 
 
40
void
 
41
simple_bzero (char *s, size_t n)
 
42
{
 
43
  simple_memset (s, 0, n);
 
44
}
 
45
 
 
46
void
 
47
builtin_bzero (char *s, size_t n)
 
48
{
 
49
  __builtin_bzero (s, n);
 
50
}
 
51
#else
24
52
typedef char *(*proto_t) (char *, int, size_t);
25
 
char *simple_memset (char *, int, size_t);
26
53
char *builtin_memset (char *, int, size_t);
27
54
 
28
55
IMPL (simple_memset, 0)
30
57
IMPL (memset, 1)
31
58
 
32
59
char *
 
60
builtin_memset (char *s, int c, size_t n)
 
61
{
 
62
  return __builtin_memset (s, c, n);
 
63
}
 
64
#endif
 
65
 
 
66
char *
33
67
simple_memset (char *s, int c, size_t n)
34
68
{
35
69
  char *r = s, *end = s + n;
38
72
  return s;
39
73
}
40
74
 
41
 
char *
42
 
builtin_memset (char *s, int c, size_t n)
43
 
{
44
 
  return __builtin_memset (s, c, n);
45
 
}
46
 
 
47
75
static void
48
 
do_one_test (impl_t *impl, char *s, int c, size_t n)
 
76
do_one_test (impl_t *impl, char *s, int c __attribute ((unused)), size_t n)
49
77
{
 
78
  char tstbuf[n];
 
79
#ifdef TEST_BZERO
 
80
  simple_bzero (tstbuf, n);
 
81
  CALL (impl, s, n);
 
82
  if (memcmp (s, tstbuf, n) != 0)
 
83
#else
50
84
  char *res = CALL (impl, s, c, n);
51
 
  char tstbuf[n];
52
85
  if (res != s
53
86
      || simple_memset (tstbuf, c, n) != tstbuf
54
87
      || memcmp (s, tstbuf, n) != 0)
 
88
#endif
55
89
    {
56
90
      error (0, 0, "Wrong result in function %s", impl->name);
57
91
      ret = 1;
68
102
      for (i = 0; i < 32; ++i)
69
103
        {
70
104
          HP_TIMING_NOW (start);
 
105
#ifdef TEST_BZERO
 
106
          CALL (impl, s, n);
 
107
#else
71
108
          CALL (impl, s, c, n);
 
109
#endif
 
110
 
72
111
          HP_TIMING_NOW (stop);
73
112
          HP_TIMING_BEST (best_time, start, stop);
74
113
        }
94
133
    putchar ('\n');
95
134
}
96
135
 
 
136
#ifndef TEST_BZERO
97
137
static void
98
138
do_random_tests (void)
99
139
{
178
218
        }
179
219
    }
180
220
}
 
221
#endif
181
222
 
182
223
int
183
224
test_main (void)
184
225
{
185
226
  size_t i;
186
 
  int c;
 
227
  int c = 0;
187
228
 
188
229
  test_init ();
189
230
 
192
233
    printf ("\t%s", impl->name);
193
234
  putchar ('\n');
194
235
 
 
236
#ifndef TEST_BZERO
195
237
  for (c = -65; c <= 130; c += 65)
 
238
#endif
196
239
    {
197
240
      for (i = 0; i < 18; ++i)
198
241
        do_test (0, c, 1 << i);
208
251
      do_test (2, c, 25);
209
252
    }
210
253
 
 
254
#ifndef TEST_BZERO
211
255
  do_random_tests ();
 
256
#endif
 
257
 
212
258
  return ret;
213
259
}
214
260