freemint / tos.hyp

The tos.hyp tries to document all functions from TOS. It also has information about MagiC, N.AES, MyAES, Geneva, XaAES, oAESis and some emulators.
https://freemint.github.io/tos.hyp
GNU General Public License v2.0
13 stars 10 forks source link

Add info about unimplemented System V IPC functions #166

Open xdelatour opened 1 year ago

xdelatour commented 1 year ago

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

Any idea what the correct values are?

th-otto commented 1 year ago

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;
    }