OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [builtins/] [sprintf.c] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 688 jeremybenn
/* Copyright (C) 2003  Free Software Foundation.
2
 
3
   Test sprintf optimizations don't break anything and return the
4
   correct results.
5
 
6
   Written by Roger Sayle, June 22, 2003.  */
7
 
8
static char buffer[32];
9
 
10
extern void abort ();
11
typedef __SIZE_TYPE__ size_t;
12
extern int sprintf(char*, const char*, ...);
13
extern void *memset(void*, int, size_t);
14
extern int memcmp(const void*, const void*, size_t);
15
 
16
void test1()
17
{
18
  sprintf(buffer,"foo");
19
}
20
 
21
int test2()
22
{
23
  return sprintf(buffer,"foo");
24
}
25
 
26
void test3()
27
{
28
  sprintf(buffer,"%s","bar");
29
}
30
 
31
int test4()
32
{
33
  return sprintf(buffer,"%s","bar");
34
}
35
 
36
void test5(char *ptr)
37
{
38
  sprintf(buffer,"%s",ptr);
39
}
40
 
41
 
42
void
43
main_test (void)
44
{
45
  memset (buffer, 'A', 32);
46
  test1 ();
47
  if (memcmp(buffer, "foo", 4) || buffer[4] != 'A')
48
    abort ();
49
 
50
  memset (buffer, 'A', 32);
51
  if (test2 () != 3)
52
    abort ();
53
  if (memcmp(buffer, "foo", 4) || buffer[4] != 'A')
54
    abort ();
55
 
56
  memset (buffer, 'A', 32);
57
  test3 ();
58
  if (memcmp(buffer, "bar", 4) || buffer[4] != 'A')
59
    abort ();
60
 
61
  memset (buffer, 'A', 32);
62
  if (test4 () != 3)
63
    abort ();
64
  if (memcmp(buffer, "bar", 4) || buffer[4] != 'A')
65
    abort ();
66
 
67
  memset (buffer, 'A', 32);
68
  test5 ("barf");
69
  if (memcmp(buffer, "barf", 5) || buffer[5] != 'A')
70
    abort ();
71
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.