source: rtems-libbsd/services/librpc/src/rpc/rtems_rpc.c @ bceabc9

4.1155-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since bceabc9 was cd450d2, checked in by Joel Sherrill <joel.sherrill@…>, on 08/06/12 at 00:10:35

librpc: now compiles

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 * RTEMS multi-tasking support
3 */
4
5#ifdef HAVE_CONFIG_H
6#include "config.h"
7#endif
8
9#include <freebsd/bsd.h>
10#include <rpc/rpc.h>
11#include <rtems.h>
12#include <stdlib.h>
13#ifdef __rtems__
14        /* XXX in rpc.h in old .. not new */
15        #include <rpc/rpc_rtems.h>
16#endif
17
18/*
19 * RPC variables for single-thread
20 */
21static struct _rtems_rpc_task_variables rpc_default = {
22        -1,             /* svc_maxfd */
23        {{0}},          /* svc_svc_fdset */
24        NULL,           /* svc_xports */
25        0,              /* svc_xportssize */
26        0,              /* svc__svc_fdsetsize */               
27        0,              /* svc__svc_fdset */
28        NULL,           /* svc_svc_head */
29        0,              /* clnt_perror_buf */
30        0,              /* clnt_raw_private */
31        0,              /* call_rpc_private */
32        0,              /* svc_raw_private */
33
34        0,              /* svc_simple_proglst */
35        0,              /* svc_simple_pl */
36        0,              /* svc_simple_transp */
37
38        0,              /* rpcdname_default_domain */
39        0               /* svc_auths_Auths */
40};
41
42/*
43 * RPC values for initializing a new per-task set of variables
44 */
45static const struct _rtems_rpc_task_variables rpc_init = {
46        -1,             /* svc_maxfd */
47        {{0}},          /* svc_svc_fdset */
48        NULL,           /* svc_xports */
49        0,              /* svc_xportssize */
50        0,              /* svc__svc_fdsetsize */               
51        0,              /* svc__svc_fdset */
52        NULL,           /* svc_svc_head */
53        0,              /* clnt_perror_buf */
54        0,              /* clnt_raw_private */
55        0,              /* call_rpc_private */
56        0,              /* svc_raw_private */
57
58        0,              /* svc_simple_proglst */
59        0,              /* svc_simple_pl */
60        0,              /* svc_simple_transp */
61
62        0,              /* rpcdname_default_domain */
63        0               /* svc_auths_Auths */
64};
65
66/*
67 * Per-task pointer to RPC data
68 */
69struct _rtems_rpc_task_variables *rtems_rpc_task_variables = &rpc_default;
70
71/*
72 * Set up per-task RPC variables
73 */
74int rtems_rpc_task_init (void)
75{
76        rtems_status_code sc;
77        struct _rtems_rpc_task_variables *tvp;
78
79        if (rtems_rpc_task_variables == &rpc_default) {
80                tvp = malloc (sizeof *tvp);
81                if (tvp == NULL)
82                        return RTEMS_NO_MEMORY;
83                /*
84                 * FIXME: Should have destructor which cleans up
85                 * all RPC stuff:
86                 *      - Close all files
87                 *      - Go through and free linked list elements
88                 *      - Free other allocated memory (e.g. clnt_perror_buf)
89                 */
90                sc = rtems_task_variable_add (
91                        RTEMS_SELF, (void *)&rtems_rpc_task_variables, NULL);
92                if (sc != RTEMS_SUCCESSFUL) {
93                        free (tvp);
94                        return sc;
95                }
96                *tvp = rpc_init;
97                rtems_rpc_task_variables = tvp;
98        }
99        return RTEMS_SUCCESSFUL;
100}
Note: See TracBrowser for help on using the repository browser.