From 9ee586625ea925b1a3182c002f0634c0a7c19046 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 21 Jan 2016 09:33:52 +0100 Subject: [PATCH] increasing the POSIX support of the IP stack --- hermit/include/sys/ipc.h | 75 +++++++++++++++++++++++++++++++++++++ hermit/include/sys/poll.h | 78 +++++++++++++++++++++++++++++++++++++++ hermit/include/sys/shm.h | 62 +++++++++++++++++++++++++++++++ hermit/lwip | 2 +- hermit/tools/netinet/in.h | 9 ++--- 5 files changed, 220 insertions(+), 6 deletions(-) create mode 100644 hermit/include/sys/ipc.h create mode 100644 hermit/include/sys/poll.h create mode 100644 hermit/include/sys/shm.h diff --git a/hermit/include/sys/ipc.h b/hermit/include/sys/ipc.h new file mode 100644 index 000000000..9dc8aff69 --- /dev/null +++ b/hermit/include/sys/ipc.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2015, Stefan Lankes, RWTH Aachen University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __SYS_IPC_H__ +#define __SYS_IPC_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __KERNEL__ +typedef long key_t; +#endif + +#define IPC_PRIVATE ((key_t) 0) + +/* Obsolete, used only for backwards compatibility and libc5 compiles */ +struct ipc_perm +{ + key_t key; +#if 0 + __kernel_uid_t uid; + __kernel_gid_t gid; + __kernel_uid_t cuid; + __kernel_gid_t cgid; + __kernel_mode_t mode; + unsigned short seq; +#endif +}; + +/* resource get request flags */ +#define IPC_CREAT 00001000 /* create if key is nonexistent */ +#define IPC_EXCL 00002000 /* fail if key exists */ +#define IPC_NOWAIT 00004000 /* return error on wait */ + +/* + * Control commands used with semctl, msgctl and shmctl + * see also specific commands in shm.h + */ +#define IPC_RMID 0 /* remove resource */ +#define IPC_SET 1 /* set ipc_perm options */ +#define IPC_STAT 2 /* get ipc_perm options */ +#define IPC_INFO 3 /* see ipcs */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/hermit/include/sys/poll.h b/hermit/include/sys/poll.h new file mode 100644 index 000000000..64502c558 --- /dev/null +++ b/hermit/include/sys/poll.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2015, Stefan Lankes, RWTH Aachen University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __SYS_POLL_H__ +#define __SYS_POLL_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* These are specified by iBCS2 */ +#define POLLIN 0x0001 +#define POLLPRI 0x0002 +#define POLLOUT 0x0004 +#define POLLERR 0x0008 +#define POLLHUP 0x0010 +#define POLLNVAL 0x0020 + +/* The rest seem to be more-or-less nonstandard. Check them! */ +#define POLLRDNORM 0x0040 +#define POLLRDBAND 0x0080 +#ifndef POLLWRNORM +#define POLLWRNORM 0x0100 +#endif +#ifndef POLLWRBAND +#define POLLWRBAND 0x0200 +#endif +#ifndef POLLMSG +#define POLLMSG 0x0400 +#endif +#ifndef POLLREMOVE +#define POLLREMOVE 0x1000 +#endif +#ifndef POLLRDHUP +#define POLLRDHUP 0x2000 +#endif + +#define POLLFREE 0x4000 /* currently only for epoll */ + +#define POLL_BUSY_LOOP 0x8000 + +struct pollfd { + int fd; + short events; + short revents; +}; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/hermit/include/sys/shm.h b/hermit/include/sys/shm.h new file mode 100644 index 000000000..df3d456e7 --- /dev/null +++ b/hermit/include/sys/shm.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2015, Stefan Lankes, RWTH Aachen University + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __SYS_SHM_H__ +#define __SYS_SHM_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct shmid_ds { + struct ipc_perm shm_perm; /* operation perms */ +#if 0 + int shm_segsz; /* size of segment (bytes) */ + __kernel_time_t shm_atime; /* last attach time */ + __kernel_time_t shm_dtime; /* last detach time */ + __kernel_time_t shm_ctime; /* last change time */ + __kernel_ipc_pid_t shm_cpid; /* pid of creator */ + __kernel_ipc_pid_t shm_lpid; /* pid of last operator */ + unsigned short shm_nattch; /* no. of current attaches */ + unsigned short shm_unused; /* compatibility */ + void *shm_unused2; /* ditto - used by DIPC */ + void *shm_unused3; /* unused */ +#endif +}; + +int shmget(key_t key, size_t size, int shmflg); +void *shmat(int shmid, const void *shmaddr, int shmflg); +int shmdt(const void *shmaddr); +int shmctl(int shmid, int cmd, struct shmid_ds *buf); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/hermit/lwip b/hermit/lwip index 86cda3ccd..e7f2fbc08 160000 --- a/hermit/lwip +++ b/hermit/lwip @@ -1 +1 @@ -Subproject commit 86cda3ccda741aa5fe6653be1f306803ddc4bab2 +Subproject commit e7f2fbc08fa700a6b89a57dcc76ac48bafc60c9e diff --git a/hermit/tools/netinet/in.h b/hermit/tools/netinet/in.h index 84c5cb4e3..235536773 100644 --- a/hermit/tools/netinet/in.h +++ b/hermit/tools/netinet/in.h @@ -13,16 +13,15 @@ #include #include +#include #ifdef __cplusplus { #endif -#if 0 -struct in_addr { - uint32_t s_addr; -}; -#endif +typedef uint16_t in_port_t; + +int inet_pton(int af, const char *src, void *dst); /** 255.255.255.255 */ #define IPADDR_NONE ((uint32_t)0xffffffffUL)