cd util && $(MAKE) $@
mkdir -p obj-ack//./sysutil
cd sysutil && $(MAKE) $@
+ mkdir -p obj-ack//./sysvipc
+ cd sysvipc && $(MAKE) $@
mkdir -p obj-ack//./timers
cd timers && $(MAKE) $@
mkdir -p obj-ack//./i386
cd util && $(MAKE) $@
mkdir -p obj-gnu/./sysutil
cd sysutil && $(MAKE) $@
+ mkdir -p obj-gnu/./sysvipc
+ cd sysvipc && $(MAKE) $@
mkdir -p obj-gnu/./timers
cd timers && $(MAKE) $@
mkdir -p obj-gnu/./i386
cd syslib && $(MAKE) $@
cd util && $(MAKE) $@
cd sysutil && $(MAKE) $@
+ cd sysvipc && $(MAKE) $@
cd timers && $(MAKE) $@
cd i386 && $(MAKE) $@
cd ack && $(MAKE) $@
makefiles: syslib/Makefile
makefiles: util/Makefile
makefiles: sysutil/Makefile
+makefiles: sysvipc/Makefile
makefiles: timers/Makefile
makefiles: i386/Makefile
makefiles: ack/Makefile
cd util && sh ../generate.sh ./util ../obj-ack/ ../obj-gnu && $(MAKE) makefiles
sysutil/Makefile: sysutil/Makefile.in
cd sysutil && sh ../generate.sh ./sysutil ../obj-ack/ ../obj-gnu && $(MAKE) makefiles
+sysvipc/Makefile: sysvipc/Makefile.in
+ cd sysvipc && sh ../generate.sh ./sysvipc ../obj-ack/ ../obj-gnu && $(MAKE) makefiles
timers/Makefile: timers/Makefile.in
cd timers && sh ../generate.sh ./timers ../obj-ack/ ../obj-gnu && $(MAKE) makefiles
i386/Makefile: i386/Makefile.in
--- /dev/null
+# Makefile for lib/posix.
+
+CFLAGS="-O -D_MINIX -D_POSIX_SOURCE"
+
+LIBRARIES=libc
+
+libc_FILES="ftok.c sem.c shm.c"
+
+TYPE=both
+
--- /dev/null
+#define _SYSTEM 1
+#define _MINIX 1
+
+#include <minix/callnr.h>
+#include <minix/com.h>
+#include <minix/config.h>
+#include <minix/ipc.h>
+#include <minix/endpoint.h>
+#include <minix/sysutil.h>
+#include <minix/syslib.h>
+#include <minix/const.h>
+#include <minix/type.h>
+#include <minix/ds.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+
+int mini_ds_retrieve_u32(char *ds_name, u32_t *value)
+{
+ int r;
+ message m;
+ size_t len_key;
+
+ len_key = strlen(ds_name)+1;
+
+ m.DS_KEY_GRANT = ds_name;
+ m.DS_KEY_LEN = len_key;
+ m.DS_FLAGS = DS_TYPE_U32;
+
+ r = _taskcall(DS_PROC_NR, DS_RETRIEVE_LIBC, &m);
+
+ if(r == OK) {
+ /* Assign u32 value. */
+ *value = m.DS_VAL;
+ }
+
+ return r;
+}
+
--- /dev/null
+#include <sys/ipc.h>
+#include <sys/stat.h>
+
+key_t ftok(const char *path, int id)
+{
+ struct stat st;
+
+ if (lstat(path, &st) < 0)
+ return (key_t) -1;
+
+ return (key_t) ((st.st_ino & 0xffff) |
+ ((st.st_dev & 0xff) << 16) |
+ ((id & 0xff) << 24));
+}
+
--- /dev/null
+#define __USE_MISC
+#define _SYSTEM 1
+#define _MINIX 1
+
+#include <minix/com.h>
+#include <minix/config.h>
+#include <minix/ipc.h>
+#include <minix/endpoint.h>
+#include <minix/sysutil.h>
+#include <minix/const.h>
+#include <minix/type.h>
+#include <minix/rs.h>
+
+#include <lib.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/sem.h>
+#include <time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <errno.h>
+
+PRIVATE int get_ipc_endpt(endpoint_t *pt)
+{
+ return minix_rs_lookup("ipc", pt);
+}
+
+/* Get semaphore. */
+PUBLIC int semget(key_t key, int nsems, int semflag)
+{
+ message m;
+ endpoint_t ipc_pt;
+ int r;
+
+ if (get_ipc_endpt(&ipc_pt) != OK) {
+ errno = ENOSYS;
+ return -1;
+ }
+
+ m.SEMGET_KEY = key;
+ m.SEMGET_NR = nsems;
+ m.SEMGET_FLAG = semflag;
+
+ r = _syscall(ipc_pt, IPC_SEMGET, &m);
+ if (r != OK)
+ return r;
+
+ return m.SEMGET_RETID;
+}
+
+/* Semaphore control operation. */
+PUBLIC int semctl(int semid, int semnum, int cmd, ...)
+{
+ message m;
+ endpoint_t ipc_pt;
+ va_list ap;
+ int r;
+
+ if (get_ipc_endpt(&ipc_pt) != OK) {
+ errno = ENOSYS;
+ return -1;
+ }
+
+ m.SEMCTL_ID = semid;
+ m.SEMCTL_NUM = semnum;
+ m.SEMCTL_CMD = cmd;
+ va_start(ap, cmd);
+ if (cmd == IPC_STAT || cmd == IPC_SET || cmd == IPC_INFO ||
+ cmd == SEM_INFO || cmd == SEM_STAT || cmd == GETALL ||
+ cmd == SETALL || cmd == SETVAL)
+ m.SEMCTL_OPT = (long) va_arg(ap, long);
+ va_end(ap);
+
+ r = _syscall(ipc_pt, IPC_SEMCTL, &m);
+ if ((r != -1) && (cmd == GETNCNT || cmd == GETZCNT || cmd == GETPID ||
+ cmd == GETVAL || cmd == IPC_INFO || cmd == SEM_INFO ||
+ cmd == SEM_STAT))
+ return m.SHMCTL_RET;
+ return r;
+}
+
+/* Operate on semaphore. */
+PUBLIC int semop(int semid, struct sembuf *sops, size_t nsops)
+{
+ message m;
+ endpoint_t ipc_pt;
+
+ if (get_ipc_endpt(&ipc_pt) != OK) {
+ errno = ENOSYS;
+ return -1;
+ }
+
+ m.SEMOP_ID = semid;
+ m.SEMOP_OPS = (long) sops;
+ m.SEMOP_SIZE = nsops;
+
+ return _syscall(ipc_pt, IPC_SEMOP, &m);
+}
+
--- /dev/null
+#define _SYSTEM 1
+#define _MINIX 1
+
+#include <minix/callnr.h>
+#include <minix/com.h>
+#include <minix/config.h>
+#include <minix/ipc.h>
+#include <minix/endpoint.h>
+#include <minix/sysutil.h>
+#include <minix/const.h>
+#include <minix/type.h>
+#include <minix/rs.h>
+
+#include <lib.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+PRIVATE int get_ipc_endpt(endpoint_t *pt)
+{
+ return minix_rs_lookup("ipc", pt);
+}
+
+/* Shared memory control operation. */
+PUBLIC int shmctl(int shmid, int cmd, struct shmid_ds *buf)
+{
+ message m;
+ endpoint_t ipc_pt;
+ int r;
+
+ if (get_ipc_endpt(&ipc_pt) != OK) {
+ errno = ENOSYS;
+ return -1;
+ }
+
+ m.SHMCTL_ID = shmid;
+ m.SHMCTL_CMD = cmd;
+ m.SHMCTL_BUF = (long) buf;
+
+ r = _syscall(ipc_pt, IPC_SHMCTL, &m);
+ if ((cmd == IPC_INFO || cmd == SHM_INFO || cmd == SHM_STAT)
+ && (r == OK))
+ return m.SHMCTL_RET;
+ return r;
+}
+
+/* Get shared memory segment. */
+PUBLIC int shmget(key_t key, size_t size, int shmflg)
+{
+ message m;
+ endpoint_t ipc_pt;
+ int r;
+
+ if (get_ipc_endpt(&ipc_pt) != OK) {
+ errno = ENOSYS;
+ return -1;
+ }
+
+ m.SHMGET_KEY = key;
+ m.SHMGET_SIZE = size;
+ m.SHMGET_FLAG = shmflg;
+
+ r = _syscall(ipc_pt, IPC_SHMGET, &m);
+ if (r != OK)
+ return r;
+ return m.SHMGET_RETID;
+}
+
+/* Attach shared memory segment. */
+PUBLIC void *shmat(int shmid, const void *shmaddr, int shmflg)
+{
+ message m;
+ endpoint_t ipc_pt;
+ int r;
+
+ if (get_ipc_endpt(&ipc_pt) != OK) {
+ errno = ENOSYS;
+ return NULL;
+ }
+
+ m.SHMAT_ID = shmid;
+ m.SHMAT_ADDR = (long) shmaddr;
+ m.SHMAT_FLAG = shmflg;
+
+ r = _syscall(ipc_pt, IPC_SHMAT, &m);
+ if (r != OK)
+ return (void *) -1;
+ return (void *) m.SHMAT_RETADDR;
+}
+
+/* Deattach shared memory segment. */
+PUBLIC int shmdt(const void *shmaddr)
+{
+ message m;
+ endpoint_t ipc_pt;
+
+ if (get_ipc_endpt(&ipc_pt) != OK) {
+ errno = ENOSYS;
+ return -1;
+ }
+
+ m.SHMDT_ADDR = (long) shmaddr;
+
+ return _syscall(ipc_pt, IPC_SHMDT, &m);
+}
+