4.104.114.84.95
Line | |
---|
1 | /* |
---|
2 | * RTEMS multi-tasking support |
---|
3 | */ |
---|
4 | |
---|
5 | #include <rpc/rpc.h> |
---|
6 | #include <rtems.h> |
---|
7 | #include <stdlib.h> |
---|
8 | |
---|
9 | /* |
---|
10 | * RPC variables for single-thread |
---|
11 | */ |
---|
12 | static struct rtems_rpc_task_variables rpc_default = { |
---|
13 | -1, /* svc_maxfd */ |
---|
14 | }; |
---|
15 | |
---|
16 | /* |
---|
17 | * RPC values for initializing a new per-task set of variables |
---|
18 | */ |
---|
19 | static const struct rtems_rpc_task_variables rpc_init = { |
---|
20 | -1, /* svc_maxfd */ |
---|
21 | }; |
---|
22 | |
---|
23 | /* |
---|
24 | * Per-task pointer to RPC data |
---|
25 | */ |
---|
26 | void *rtems_rpc_task_variables = &rpc_default; |
---|
27 | |
---|
28 | /* |
---|
29 | * Set up per-task RPC variables |
---|
30 | */ |
---|
31 | int rtems_rpc_task_init (void) |
---|
32 | { |
---|
33 | rtems_status_code sc; |
---|
34 | struct rtems_rpc_task_variables *tvp; |
---|
35 | |
---|
36 | if (rtems_rpc_task_variables == &rpc_default) { |
---|
37 | tvp = malloc (sizeof *tvp); |
---|
38 | if (tvp == NULL) |
---|
39 | return RTEMS_NO_MEMORY; |
---|
40 | /* |
---|
41 | * FIXME: Should have destructor which cleans up |
---|
42 | * all RPC stuff: |
---|
43 | * - Close all files |
---|
44 | * - Go through and free linked list elements |
---|
45 | * - Free other allocated memory (e.g. clnt_perror_buf) |
---|
46 | */ |
---|
47 | sc = rtems_task_variable_add (RTEMS_SELF, &rtems_rpc_task_variables, NULL); |
---|
48 | if (sc != RTEMS_SUCCESSFUL) { |
---|
49 | free (tvp); |
---|
50 | return sc; |
---|
51 | } |
---|
52 | *tvp = rpc_init; |
---|
53 | rtems_rpc_task_variables = tvp; |
---|
54 | } |
---|
55 | return RTEMS_SUCCESSFUL; |
---|
56 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.