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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [sim/] [testsuite/] [sim/] [cris/] [c/] [clone4.c] - Blame information for rev 227

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

Line No. Rev Author Line
1 227 jeremybenn
/* Check that TRT happens when we reach the #threads implementation limit.
2
#notarget: cris*-*-elf
3
*/
4
 
5
#include <stddef.h>
6
#include <stdlib.h>
7
#include <stdio.h>
8
#include <limits.h>
9
#include <unistd.h>
10
#include <sched.h>
11
#include <errno.h>
12
#include <sys/types.h>
13
#include <sys/wait.h>
14
 
15
int
16
process (void *arg)
17
{
18
  int i;
19
 
20
  for (i = 0; i < 500; i++)
21
    if (sched_yield ())
22
      abort ();
23
 
24
  return 0;
25
}
26
 
27
int
28
main (void)
29
{
30
  int pid;
31
  int i;
32
  int stacksize = 16384;
33
 
34
  for (i = 0; i < 1000; i++)
35
    {
36
      char *stack = malloc (stacksize);
37
      if (stack == NULL)
38
        abort ();
39
 
40
      pid = clone (process, (char *) stack + stacksize - 64,
41
                   (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND)
42
                   | SIGCHLD, "ab");
43
      if (pid <= 0)
44
        {
45
          /* FIXME: Read sysconf instead of magic number.  */
46
          if (i < 60)
47
            {
48
              fprintf (stderr, "Bad clone %d\n", pid);
49
              abort ();
50
            }
51
 
52
          if (errno == EAGAIN)
53
            {
54
              printf ("pass\n");
55
              exit (0);
56
            }
57
        }
58
    }
59
 
60
  abort ();
61
}

powered by: WebSVN 2.1.0

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