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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [runtime/] [yield.c] - Blame information for rev 753

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

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2011 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
#include "config.h"
6
 
7
#include <stddef.h>
8
#include <sys/types.h>
9
#include <sys/time.h>
10
#include <sched.h>
11
#include <unistd.h>
12
 
13
#ifdef HAVE_SYS_SELECT_H
14
#include <sys/select.h>
15
#endif
16
 
17
#include "runtime.h"
18
 
19
/* Spin wait.  */
20
 
21
void
22
runtime_procyield (uint32 cnt)
23
{
24
  volatile uint32 i;
25
 
26
  for (i = 0; i < cnt; ++i)
27
    {
28
#if defined (__i386__) || defined (__x86_64__)
29
      __builtin_ia32_pause ();
30
#endif
31
    }
32
}
33
 
34
/* Ask the OS to reschedule this thread.  */
35
 
36
void
37
runtime_osyield (void)
38
{
39
  sched_yield ();
40
}
41
 
42
/* Sleep for some number of microseconds.  */
43
 
44
void
45
runtime_usleep (uint32 us)
46
{
47
  struct timeval tv;
48
 
49
  tv.tv_sec = us / 1000000;
50
  tv.tv_usec = us % 1000000;
51
  select (0, NULL, NULL, NULL, &tv);
52
}

powered by: WebSVN 2.1.0

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