Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add info about unimplemented System V IPC functions #166

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

xdelatour
Copy link
Contributor

  • semctl() commands are 0/1/2 (IPC_RMID/SET/STAT) and from 11 (GETPID) to 17 (SETALL). These values are defined in MiNTLib (include/bits/sem.h)
  • However, in FreeMiNT, no changes for 0/1/2 but other commands are from 3 (GETNCNT) to 9 (SETALL) (sys/mint/sem.h).

semctl() is equivalent to Psemctl() (semctl.c)

Any idea what the correct values are?

@th-otto
Copy link
Contributor

th-otto commented Aug 12, 2023

Any idea what the correct values are?

Since it is not yet implemented, we would still have to make them up ;)

Values in mintlib do not neccessarily have to be the same as used in the kernel, but of course that would make the implementation in mintlib easier.

I do not now where the values in the kernel (https://github.com/freemint/freemint/blob/3dd75deb4ce6d77f281ccf6ef4b6621aaa0e8d9d/sys/mint/sem.h#L76) originally came from, but the values in mintlib are from current glibc, and i would recommend to use them. That would be:

/* Control commands for `msgctl', `semctl', and `shmctl'.  */
#define IPC_RMID	0		/* Remove identifier.  */
#define IPC_SET		1		/* Set `ipc_perm' options.  */
#define IPC_STAT	2		/* Get `ipc_perm' options.  */
#ifdef __USE_GNU
# define IPC_INFO	3		/* See ipcs.  */
#endif

/* Commands for `semctl'.  */
#define GETPID		11		/* get sempid */
#define GETVAL		12		/* get semval */
#define GETALL		13		/* get all semval's */
#define GETNCNT		14		/* get semncnt */
#define GETZCNT		15		/* get semzcnt */
#define SETVAL		16		/* set semval */
#define SETALL		17		/* set all semval's */

/* ipcs ctl cmds */
# define SHM_STAT 	13
# define SHM_INFO 	14
# define SHM_STAT_ANY	15
# define SEM_STAT 18
# define SEM_INFO 19
# define SEM_STAT_ANY 20

And glibc uses these values:

  /* Get the argument only if required.  */
  switch (cmd)
    {
    case SETVAL:        /* arg.val */
    case GETALL:        /* arg.array */
    case SETALL:
    case IPC_STAT:      /* arg.buf */
    case IPC_SET:
    case SEM_STAT:
    case SEM_STAT_ANY:
    case IPC_INFO:      /* arg.__buf */
    case SEM_INFO:
      va_start (ap, cmd);
      arg64 = va_arg (ap, union semun64);
      va_end (ap);
      break;
    case IPC_RMID:      /* arg ignored.  */
    case GETNCNT:
    case GETPID:
    case GETVAL:
    case GETZCNT:
      break;
    default:
      __set_errno (EINVAL);
      return -1;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants