int
main (void)
{
  setbuf (stdout, NULL);
  printf ("main: %d\n", (int) getpid ());

  /* General hardware breakpoints and watchpoints validity.  */
  marker ();
  var++;
  /* Hardware watchpoints got disarmed here.  */
  forkoff (1);
  /* This watchpoint got lost before.  */
  var++;
  /* A sanity check for double hardware watchpoints removal.  */
  forkoff (2);
  var++;

  mark_exit ();
  return 0;
}
int
main (void)
{
  int i;
  void *thread_result;

  setbuf (stdout, NULL);
  printf ("main: %d\n", (int) gettid ());

  /* General hardware breakpoints and watchpoints validity.  */
  marker ();
  var++;	/* validity-first */
  empty ();	/* validity-first */

  i = pthread_create (&thread, NULL, start, NULL);
  assert (i == 0);

  var++;	/* validity-thread-A */
  empty ();	/* validity-thread-A */
  step = 1;
  while (step != 2)
    {
      i = pthread_yield ();
      assert (i == 0);
    }

  /* Hardware watchpoints got disarmed here.  */
  forkoff (1);

  var++;	/* after-fork1-A */
  empty ();	/* after-fork1-A */
  step = 3;
#ifdef FOLLOW_CHILD
  /* Spawn new thread as it was deleted in the child of FORK.  */
  i = pthread_create (&thread, NULL, start, NULL);
  assert (i == 0);
#endif
  while (step != 4)
    {
      i = pthread_yield ();
      assert (i == 0);
    }

  /* A sanity check for double hardware watchpoints removal.  */
  forkoff (2);

  var++;	/* after-fork2-A */
  empty ();	/* after-fork2-A */
  step = 5;
#ifdef FOLLOW_CHILD
  /* Spawn new thread as it was deleted in the child of FORK.  */
  i = pthread_create (&thread, NULL, start, NULL);
  assert (i == 0);
#endif

  i = pthread_join (thread, &thread_result);
  assert (i == 0);
  assert (thread_result == (void *) 5UL);

  mark_exit ();
  return 0;
}