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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.base/] [run.c] - Diff between revs 107 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 107 Rev 1765
/*
/*
 *      This simple classical example of recursion is useful for
 *      This simple classical example of recursion is useful for
 *      testing stack backtraces and such.
 *      testing stack backtraces and such.
 */
 */
 
 
#ifdef vxworks
#ifdef vxworks
 
 
#  include <stdio.h>
#  include <stdio.h>
 
 
/* VxWorks does not supply atoi.  */
/* VxWorks does not supply atoi.  */
static int
static int
atoi (z)
atoi (z)
     char *z;
     char *z;
{
{
  int i = 0;
  int i = 0;
 
 
  while (*z >= '0' && *z <= '9')
  while (*z >= '0' && *z <= '9')
    i = i * 10 + (*z++ - '0');
    i = i * 10 + (*z++ - '0');
  return i;
  return i;
}
}
 
 
/* I don't know of any way to pass an array to VxWorks.  This function
/* I don't know of any way to pass an array to VxWorks.  This function
   can be called directly from gdb.  */
   can be called directly from gdb.  */
 
 
vxmain (arg)
vxmain (arg)
char *arg;
char *arg;
{
{
  char *argv[2];
  char *argv[2];
 
 
  argv[0] = "";
  argv[0] = "";
  argv[1] = arg;
  argv[1] = arg;
  main (2, argv, (char **) 0);
  main (2, argv, (char **) 0);
}
}
 
 
#else /* ! vxworks */
#else /* ! vxworks */
#  include <stdio.h>
#  include <stdio.h>
#  include <stdlib.h>
#  include <stdlib.h>
#endif /* ! vxworks */
#endif /* ! vxworks */
 
 
#ifdef PROTOTYPES
#ifdef PROTOTYPES
int factorial (int);
int factorial (int);
 
 
int
int
main (int argc, char **argv, char **envp)
main (int argc, char **argv, char **envp)
#else
#else
int
int
main (argc, argv, envp)
main (argc, argv, envp)
int argc;
int argc;
char *argv[], **envp;
char *argv[], **envp;
#endif
#endif
{
{
#ifdef usestubs
#ifdef usestubs
    set_debug_traps();
    set_debug_traps();
    breakpoint();
    breakpoint();
#endif
#endif
#ifdef FAKEARGV
#ifdef FAKEARGV
    printf ("%d\n", factorial (1));
    printf ("%d\n", factorial (1));
#else    
#else    
    if (argc != 2) {
    if (argc != 2) {
        printf ("usage:  factorial <number>\n");
        printf ("usage:  factorial <number>\n");
        return 1;
        return 1;
    } else {
    } else {
        printf ("%d\n", factorial (atoi (argv[1])));
        printf ("%d\n", factorial (atoi (argv[1])));
    }
    }
#endif
#endif
    return 0;
    return 0;
}
}
 
 
#ifdef PROTOTYPES
#ifdef PROTOTYPES
int factorial (int value)
int factorial (int value)
#else
#else
int factorial (value) int value;
int factorial (value) int value;
#endif
#endif
{
{
    int  local_var;
    int  local_var;
 
 
    if (value > 1) {
    if (value > 1) {
        value *= factorial (value - 1);
        value *= factorial (value - 1);
    }
    }
    local_var = value;
    local_var = value;
    return (value);
    return (value);
}
}
 
 

powered by: WebSVN 2.1.0

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