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

4.1155-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since d652c3b was e599318, checked in by Sebastian Huber <sebastian.huber@…>, on 10/09/13 at 20:52:54

Update files to match FreeBSD layout

Add compatibility with Newlib header files. Some FreeBSD header files
are mapped by the translation script:

o rtems/bsd/sys/_types.h
o rtems/bsd/sys/errno.h
o rtems/bsd/sys/lock.h
o rtems/bsd/sys/param.h
o rtems/bsd/sys/resource.h
o rtems/bsd/sys/time.h
o rtems/bsd/sys/timespec.h
o rtems/bsd/sys/types.h
o rtems/bsd/sys/unistd.h

It is now possible to include <sys/socket.h> directly for example.

Generate one Makefile which builds everything including tests.

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