summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/sys
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-07-02 08:21:37 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-07-04 07:20:37 +0200
commit94b5368388f51b535256b65d278998a48b0c4a3f (patch)
tree2e8b568f20af185ded11a246cc08be6c1175202a /freebsd/sys/sys
parentBPF(9): Pass flags to bpfopen() (diff)
downloadrtems-libbsd-94b5368388f51b535256b65d278998a48b0c4a3f.tar.bz2
Avoid malloc() in getsockaddr()
The getsockaddr() function is used to allocate a struct sockaddr of the right length and initialize it with userspace provided data. It is used for the connect(), bind() and sendit() family functions. In particular, the sendit() function is used by the UDP send functions. This means each UDP send needs a malloc() and free() invocation. This is a performance problem in RTEMS (first-fit heap) and may lead to heap fragmentation. Replace the malloc() allocation with a stack allocation. This requires SOCK_MAXADDRLEN (= 255) of additional stack space for libbsd. A further optimization would be to get rid of the stack copy of the socket address. However, this would require to check each consumer of the address to ensure that it is not modified.
Diffstat (limited to 'freebsd/sys/sys')
-rw-r--r--freebsd/sys/sys/socketvar.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/freebsd/sys/sys/socketvar.h b/freebsd/sys/sys/socketvar.h
index dd1ec474..245a687b 100644
--- a/freebsd/sys/sys/socketvar.h
+++ b/freebsd/sys/sys/socketvar.h
@@ -342,7 +342,9 @@ struct uio;
/*
* From uipc_socket and friends
*/
+#ifndef __rtems__
int getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len);
+#endif /* __rtems__ */
int getsock_cap(struct thread *td, int fd, cap_rights_t *rightsp,
struct file **fpp, u_int *fflagp, struct filecaps *havecaps);
void soabort(struct socket *so);