summaryrefslogtreecommitdiff
path: root/pfinet/glue-include/linux/sched.h
blob: 897a2df05a836eb0508649406e522f90831e40e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#ifndef _HACK_SCHED_H
#define _HACK_SCHED_H

#include <sys/signal.h>
#include <sys/time.h>
#include <mach.h>
#include <hurd/hurd_types.h>
#include <limits.h>
#include <assert.h>
#include <cthreads.h>

#include "mapped-time.h"

#include <linux/binfmts.h>
#include <linux/personality.h>
#include <linux/tasks.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/times.h>
#include <linux/timex.h>

#include <asm/system.h>
#if 0
#include <asm/semaphore.h>
#include <asm/page.h>

#include <linux/smp.h>
#include <linux/tty.h>
#include <linux/sem.h>
#include <linux/signal.h>
#include <linux/securebits.h>
#endif

#include <linux/kernel.h>
#include <linux/net.h>
#include <linux/wait.h>
#include <linux/timer.h>


#define jiffies (fetch_jiffies ())

#define current	(&current_contents)
extern struct task_struct current_contents;
struct task_struct
{
  uid_t pgrp, pid;
  int flags;
  int timeout;
  int signal;
  int blocked;
  int state, policy;
  int isroot;
  char *comm;
  struct wait_queue **next_wait;
};

static inline void
prepare_current (int isroot)
{
  current->signal = 0;
  current->isroot = isroot;
  /* All other members are constant zero and ignored.  */
}
#define become_task(user)		prepare_current ((user)->isroot)
#define become_task_protid(protid)	prepare_current ((protid)->isroot)

#define signal_pending(current)	((current)->signal)

/* FLAGS in task_struct's. */
#define PF_EXITING 1
/* STATE in task_struct's. */
#define TASK_INTERRUPTIBLE 0
#define TASK_RUNNING 0
/* policy in task_struct's. */
#define SCHED_YIELD 0

struct semaphore { };


extern inline int
suser ()
{
  return current->isroot;
};

extern inline int
capable(int cap)
{
  return current->isroot;
}


extern struct mutex global_lock;

static inline void
interruptible_sleep_on (struct wait_queue **p)
{
  struct condition **condp = (void *) p, *c;
  int isroot;
  struct wait_queue **next_wait;

  c = *condp;
  if (c == 0)
    {
      c = malloc (sizeof **condp);
      assert (c);
      condition_init (c);
      *condp = c;
    }

  isroot = current->isroot;	/* This is our context that needs switched.  */
  next_wait = current->next_wait; /* This too, for multiple schedule calls.  */
  current->next_wait = 0;
  if (hurd_condition_wait (c, &global_lock))
    current->signal = 1;	/* We got cancelled, mark it for later.  */
  current->isroot = isroot;	/* Switch back to our context.  */
  current->next_wait = next_wait;
}
#define sleep_on	interruptible_sleep_on

static inline void
wake_up_interruptible (struct wait_queue **p)
{
  struct condition **condp = (void *) p, *c = *condp;
  if (c)
    condition_broadcast (c);
}
#define wake_up		wake_up_interruptible


static inline void
add_wait_queue(struct wait_queue ** p, struct wait_queue * wait)
{
  assert (current->next_wait == 0);
  current->next_wait = p;
}

static inline void
remove_wait_queue(struct wait_queue ** p, struct wait_queue * wait)
{
  assert (current->next_wait == p);
  current->next_wait = 0;
}

static inline void
schedule (void)
{
  assert (current->next_wait);
  interruptible_sleep_on (current->next_wait);
}

static inline long
schedule_timeout (long timeout)
{
  /* XXX this is only ever called to do SO_LINGER, which we don't support */
  assert (!"schedule_timeout");
  return 0;
}

#define	MAX_SCHEDULE_TIMEOUT	LONG_MAX

/* This function is used only to send SIGPIPE to the current
   task.  In all such cases, EPIPE is returned anyhow.  In the
   Hurd, servers are not responsible for SIGPIPE; the library
   does that itself upon receiving EPIPE.  So we can just
   NOP such calls.  */
extern inline int
send_sig (u_long signo, struct task_struct *task, int priv)
{
  assert (signo == SIGPIPE);
  assert (task == current);
  return 0;
}


#endif