From 19e8ad309f034ccbd43b9a6ffb968d74f9a8bffe Mon Sep 17 00:00:00 2001 From: Enrico Fraccaroli Date: Mon, 8 May 2023 12:53:17 +0200 Subject: [PATCH] Move IPC stuff from the libc side, inside the sys folder. --- libc/CMakeLists.txt | 2 +- libc/inc/{ipc => sys}/ipc.h | 1 + libc/inc/{ipc => sys}/msg.h | 3 ++- libc/inc/{ipc => sys}/sem.h | 3 ++- libc/inc/{ipc => sys}/shm.h | 4 ++-- libc/src/{ipc => sys}/ipc.c | 14 ++++++-------- mentos/src/io/proc_ipc.c | 8 ++++---- mentos/src/ipc/msg.c | 4 ++-- mentos/src/ipc/sem.c | 5 +++-- mentos/src/ipc/shm.c | 2 +- mentos/src/system/syscall.c | 10 +++++----- programs/ipcrm.c | 4 ++-- programs/ipcs.c | 4 ++-- programs/tests/t_sem1.c | 4 ++-- programs/tests/t_semflg.c | 10 +++++----- programs/tests/t_semget.c | 10 +++++----- 16 files changed, 45 insertions(+), 43 deletions(-) rename libc/inc/{ipc => sys}/ipc.h (98%) rename libc/inc/{ipc => sys}/msg.h (99%) rename libc/inc/{ipc => sys}/sem.h (99%) rename libc/inc/{ipc => sys}/shm.h (99%) rename libc/src/{ipc => sys}/ipc.c (96%) diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index bd8ae41..2a63521 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -100,7 +100,7 @@ add_library( ${PROJECT_SOURCE_DIR}/src/io/mm_io.c ${PROJECT_SOURCE_DIR}/src/io/port_io.c ${PROJECT_SOURCE_DIR}/src/io/debug.c - ${PROJECT_SOURCE_DIR}/src/ipc/ipc.c + ${PROJECT_SOURCE_DIR}/src/sys/ipc.c ${PROJECT_SOURCE_DIR}/src/sys/unistd.c ${PROJECT_SOURCE_DIR}/src/sys/errno.c ${PROJECT_SOURCE_DIR}/src/sys/utsname.c diff --git a/libc/inc/ipc/ipc.h b/libc/inc/sys/ipc.h similarity index 98% rename from libc/inc/ipc/ipc.h rename to libc/inc/sys/ipc.h index b5d9aa9..bcbdf87 100644 --- a/libc/inc/ipc/ipc.h +++ b/libc/inc/sys/ipc.h @@ -6,6 +6,7 @@ #pragma once #include "sys/types.h" +#include "stddef.h" #define IPC_CREAT 01000 ///< Create key if key does not exist. #define IPC_EXCL 02000 ///< Fail if key exists. diff --git a/libc/inc/ipc/msg.h b/libc/inc/sys/msg.h similarity index 99% rename from libc/inc/ipc/msg.h rename to libc/inc/sys/msg.h index c04e958..ca509e9 100644 --- a/libc/inc/ipc/msg.h +++ b/libc/inc/sys/msg.h @@ -5,10 +5,11 @@ #pragma once +#include "sys/ipc.h" + #include "sys/types.h" #include "stddef.h" #include "time.h" -#include "ipc.h" /// Type for storing the number of messages in a message queue. typedef unsigned int msgqnum_t; diff --git a/libc/inc/ipc/sem.h b/libc/inc/sys/sem.h similarity index 99% rename from libc/inc/ipc/sem.h rename to libc/inc/sys/sem.h index 9024358..77579c9 100644 --- a/libc/inc/ipc/sem.h +++ b/libc/inc/sys/sem.h @@ -6,9 +6,10 @@ #pragma once #include "sys/types.h" +#include "sys/ipc.h" + #include "stddef.h" #include "time.h" -#include "ipc.h" #define SEM_UNDO 0x1000 ///< Undo the operation on exit. diff --git a/libc/inc/ipc/shm.h b/libc/inc/sys/shm.h similarity index 99% rename from libc/inc/ipc/shm.h rename to libc/inc/sys/shm.h index deb9192..d4c2838 100644 --- a/libc/inc/ipc/shm.h +++ b/libc/inc/sys/shm.h @@ -5,10 +5,11 @@ #pragma once +#include "sys/ipc.h" + #include "sys/types.h" #include "stddef.h" #include "time.h" -#include "ipc.h" /// Data type for storing the number of attaches. typedef unsigned long shmatt_t; @@ -39,7 +40,6 @@ struct shmid_ds { #if 0 -#include "ipc.h" #include "debug.h" #include "time.h" #include "kheap.h" diff --git a/libc/src/ipc/ipc.c b/libc/src/sys/ipc.c similarity index 96% rename from libc/src/ipc/ipc.c rename to libc/src/sys/ipc.c index 9b6aef0..d75bdad 100644 --- a/libc/src/ipc/ipc.c +++ b/libc/src/sys/ipc.c @@ -4,20 +4,18 @@ /// See LICENSE.md for details. #include "sys/unistd.h" -#include "system/syscall_types.h" #include "sys/errno.h" +#include "sys/stat.h" +#include "sys/sem.h" +#include "sys/shm.h" +#include "sys/msg.h" + +#include "system/syscall_types.h" #include "stddef.h" #include "string.h" #include "io/debug.h" #include "stdio.h" -#include "ipc/sem.h" -#include "ipc/shm.h" -#include "ipc/msg.h" #include "stdlib.h" -#include "ipc/sem.h" -#include "ipc/shm.h" -#include "ipc/msg.h" -#include "sys/stat.h" #include "io/debug.h" #include "stdio.h" diff --git a/mentos/src/io/proc_ipc.c b/mentos/src/io/proc_ipc.c index 048563e..11153de 100644 --- a/mentos/src/io/proc_ipc.c +++ b/mentos/src/io/proc_ipc.c @@ -3,15 +3,15 @@ /// @copyright (c) 2014-2022 This file is distributed under the MIT License. /// See LICENSE.md for details. -#include "fs/procfs.h" #include "process/process.h" #include "sys/errno.h" +#include "fs/procfs.h" #include "io/debug.h" +#include "sys/msg.h" +#include "sys/sem.h" +#include "sys/shm.h" #include "string.h" -#include "ipc/msg.h" -#include "ipc/sem.h" -#include "ipc/shm.h" extern ssize_t procipc_msg_read(vfs_file_t *file, char *buf, off_t offset, size_t nbyte); diff --git a/mentos/src/ipc/msg.c b/mentos/src/ipc/msg.c index f133ffe..0a57da6 100644 --- a/mentos/src/ipc/msg.c +++ b/mentos/src/ipc/msg.c @@ -12,10 +12,10 @@ #include "io/debug.h" // Include debugging functions. // ============================================================================ -#include "ipc/msg.h" -#include "system/panic.h" #include "process/process.h" +#include "system/panic.h" #include "sys/errno.h" +#include "sys/msg.h" #include "string.h" #include "assert.h" #include "stdio.h" diff --git a/mentos/src/ipc/sem.c b/mentos/src/ipc/sem.c index 116eaab..57ac59c 100644 --- a/mentos/src/ipc/sem.c +++ b/mentos/src/ipc/sem.c @@ -38,9 +38,10 @@ #include "io/debug.h" // Include debugging functions. // ============================================================================ -#include "ipc/sem.h" -#include "klib/list.h" +#include "sys/sem.h" + #include "process/process.h" +#include "klib/list.h" #include "sys/errno.h" #include "string.h" #include "assert.h" diff --git a/mentos/src/ipc/shm.c b/mentos/src/ipc/shm.c index e5577f6..7c0d0ff 100644 --- a/mentos/src/ipc/shm.c +++ b/mentos/src/ipc/shm.c @@ -12,7 +12,7 @@ #include "io/debug.h" // Include debugging functions. // ============================================================================ -#include "ipc/shm.h" +#include "sys/shm.h" #include "system/panic.h" #include "process/process.h" #include "sys/errno.h" diff --git a/mentos/src/system/syscall.c b/mentos/src/system/syscall.c index a6d1ff8..ad32974 100644 --- a/mentos/src/system/syscall.c +++ b/mentos/src/system/syscall.c @@ -13,17 +13,17 @@ #include "mem/kheap.h" #include "system/syscall.h" #include "descriptor_tables/isr.h" -#include "sys/errno.h" #include "kernel.h" #include "process/process.h" #include "process/scheduler.h" -#include "sys/utsname.h" #include "fs/ioctl.h" #include "hardware/timer.h" -#include "ipc/msg.h" -#include "ipc/sem.h" -#include "ipc/shm.h" +#include "sys/errno.h" +#include "sys/utsname.h" +#include "sys/msg.h" +#include "sys/sem.h" +#include "sys/shm.h" /// The signature of a function call. typedef int (*SystemCall)(); diff --git a/programs/ipcrm.c b/programs/ipcrm.c index d783fef..078bbc3 100644 --- a/programs/ipcrm.c +++ b/programs/ipcrm.c @@ -5,8 +5,8 @@ #include #include -#include -#include +#include +#include #include diff --git a/programs/ipcs.c b/programs/ipcs.c index 633a7e3..7b3c368 100644 --- a/programs/ipcs.c +++ b/programs/ipcs.c @@ -5,8 +5,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/programs/tests/t_sem1.c b/programs/tests/t_sem1.c index 31718be..4caf2b2 100644 --- a/programs/tests/t_sem1.c +++ b/programs/tests/t_sem1.c @@ -1,7 +1,7 @@ //test -#include "ipc/sem.h" +#include "sys/sem.h" #include "stdio.h" -#include "ipc/ipc.h" +#include "sys/ipc.h" #include "sys/errno.h" #include "sys/wait.h" #include "stdlib.h" diff --git a/programs/tests/t_semflg.c b/programs/tests/t_semflg.c index f7a3423..4ce4463 100644 --- a/programs/tests/t_semflg.c +++ b/programs/tests/t_semflg.c @@ -1,10 +1,10 @@ //test -#include "ipc/sem.h" -#include "stdio.h" -#include "ipc/ipc.h" -#include "sys/errno.h" -#include "stdlib.h" #include "sys/unistd.h" +#include "sys/errno.h" +#include "sys/sem.h" +#include "sys/ipc.h" +#include "stdlib.h" +#include "stdio.h" /* Testing IPC_NOWAIT flag. diff --git a/programs/tests/t_semget.c b/programs/tests/t_semget.c index 094b2cd..29b01b0 100644 --- a/programs/tests/t_semget.c +++ b/programs/tests/t_semget.c @@ -1,10 +1,10 @@ //test -#include "ipc/sem.h" -#include "stdio.h" -#include "ipc/ipc.h" -#include "sys/errno.h" -#include "stdlib.h" #include "sys/unistd.h" +#include "sys/errno.h" +#include "sys/sem.h" +#include "sys/ipc.h" +#include "stdlib.h" +#include "stdio.h" /* Testing Semaphores.