|
|
| version 1.2, 2025/02/28 20:51:20 | version 1.7, 2025/04/09 19:52:02 |
|---|---|
| Line 1 | Line 1 |
| /* | /* |
| * * | * $Id$ |
| * * * | |
| * * * | |
| * *************** | |
| * * * * * | |
| * * MUMPS * | |
| * * * * * | |
| * *************** | |
| * * * | |
| * * * | |
| * * | |
| * | |
| * shmmgr.c | |
| * shared memory manager | * shared memory manager |
| * | * |
| * | * |
| * Author: Serena Willis <jpw@coherent-logic.com> | * Author: Serena Willis <snw@coherent-logic.com> |
| * Copyright (C) 1998 MUG Deutschland | * Copyright (C) 1998 MUG Deutschland |
| * Copyright (C) 2020 Coherent Logic Development LLC | * Copyright (C) 2020, 2025 Coherent Logic Development LLC |
| * | * |
| * | * |
| * This file is part of FreeM. | * This file is part of FreeM. |
| Line 35 | Line 23 |
| * You should have received a copy of the GNU Affero Public License | * You should have received a copy of the GNU Affero Public License |
| * along with FreeM. If not, see <https://www.gnu.org/licenses/>. | * along with FreeM. If not, see <https://www.gnu.org/licenses/>. |
| * | * |
| * $Log$ | |
| * Revision 1.7 2025/04/09 19:52:02 snw | |
| * Eliminate as many warnings as possible while building with -Wall | |
| * | |
| * Revision 1.6 2025/04/04 19:43:18 snw | |
| * Switch to using environment catalog to determine user and group for environment, and remove -u and -g flags from freem | |
| * | |
| * Revision 1.5 2025/03/24 02:56:50 snw | |
| * Shared memory compatibility fixes for OS/2 | |
| * | |
| * Revision 1.4 2025/03/09 19:50:47 snw | |
| * Second phase of REUSE compliance and header reformat | |
| * | |
| * | |
| * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC | |
| * SPDX-License-Identifier: AGPL-3.0-or-later | |
| **/ | **/ |
| #include <stdlib.h> | #include <stdlib.h> |
| Line 53 | Line 57 |
| #include <sys/ipc.h> | #include <sys/ipc.h> |
| #include <sys/sem.h> | #include <sys/sem.h> |
| #if !defined(__OpenBSD__) && !defined(__APPLE__) | #if !defined(__OpenBSD__) && !defined(__APPLE__) && !defined(__OS2__) |
| union semun { | union semun { |
| int val; /* Value for SETVAL */ | int val; /* Value for SETVAL */ |
| struct semid_ds *buf; /* Buffer for IPC_STAT, IPC_SET */ | struct semid_ds *buf; /* Buffer for IPC_STAT, IPC_SET */ |
| Line 75 shm_config_t *shm_config = (shm_config_t | Line 79 shm_config_t *shm_config = (shm_config_t |
| short shm_init(const size_t seg_size) | short shm_init(const size_t seg_size) |
| { | { |
| union semun arg; | |
| size_t alloc_map_size; | size_t alloc_map_size; |
| long pg_size; | long pg_size; |
| register int i; | |
| key_t shm_sk; | key_t shm_sk; |
| shm_sk = ftok (config_file, 5); | shm_sk = ftok (config_file, 5); |
| Line 97 short shm_init(const size_t seg_size) | Line 99 short shm_init(const size_t seg_size) |
| shm_config->key = ftok (config_file, 1); | shm_config->key = ftok (config_file, 1); |
| shm_config->pgsiz = pg_size; | shm_config->pgsiz = pg_size; |
| shm_config->seg_id = shmget (shm_config->key, shm_config->segsiz, 0660 | IPC_CREAT); | shm_config->seg_id = shmget (shm_config->key, shm_config->segsiz, 0770 | IPC_CREAT); |
| if (shm_config->seg_id == -1) { | if (shm_config->seg_id == -1) { |
| if (errno == 22) { | if (errno == 22) { |
| fprintf (stderr, "shm_init: cannot get shared memory segment of %ld bytes\r\n\r\n", (unsigned long) shm_config->segsiz); | fprintf (stderr, "shm_init: cannot get shared memory segment of %ld bytes\r\n\r\n", (unsigned long) shm_config->segsiz); |
| Line 199 short shm_init(const size_t seg_size) | Line 201 short shm_init(const size_t seg_size) |
| void shm_daemon_init(void) | void shm_daemon_init(void) |
| { | { |
| union semun arg; | union semun arg; |
| size_t alloc_map_size; | |
| key_t shm_sk; | key_t shm_sk; |
| register int i; | register int i; |
| Line 475 void shm_dump(void) | Line 476 void shm_dump(void) |
| printf ("SHARED MEMORY CONFIGURATION\r\n"); | printf ("SHARED MEMORY CONFIGURATION\r\n"); |
| printf (" pgsiz %ld\r\n", (unsigned long) shm_config->pgsiz); | printf (" pgsiz %ld\r\n", (unsigned long) shm_config->pgsiz); |
| printf (" pgct %d\r\n", shm_config->pgct); | printf (" pgct %d\r\n", shm_config->pgct); |
| printf (" key %ld\r\n", shm_config->key); | printf (" key %d\r\n", shm_config->key); |
| printf (" segid %d\r\n", shm_config->seg_id); | printf (" segid %d\r\n", shm_config->seg_id); |
| printf (" sizeof shm_page_t %ld\r\n", (long) sizeof (shm_page_t)); | printf (" sizeof shm_page_t %ld\r\n", (long) sizeof (shm_page_t)); |
| printf (" segsiz %ld\r\n", (long) shm_config->segsiz); | printf (" segsiz %ld\r\n", (long) shm_config->segsiz); |