First patch by Salvatore to implement XSI semaphores with a few changes
by myself: * renamed xsi_do_undo() to xsi_sem_undo() (there is more to XSI than sems). * Fixed coding style issues in sys/sem.h and xsi_sem.cpp. * Added _kern_*() syscall prototypes to syscalls.h. * Added a TODO in xsi_sem.cpp and xsi_semaphore.h about moving union semun to a shared header. * Made the team::xsi_sem_undo_requests int32 - due to padding, it would have needed 4 bytes anyway; please always use specific types over int/short/long. * xsi_sem_undo() now checks if it needs to do anything - the calls in team.cpp no longer needs to do this. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26676 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+7
-11
@@ -6,8 +6,8 @@
|
||||
#define _SYS_IPC_H
|
||||
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
#error functionality has not yet been implemented
|
||||
|
||||
|
||||
/* Mode bits for msgget(), semget(), and shmget() */
|
||||
@@ -17,15 +17,15 @@
|
||||
|
||||
/* Control commands for msgctl(), semctl(), and shmctl() */
|
||||
#define IPC_RMID 0 /* remove identifier */
|
||||
#define IPC_SET 1
|
||||
#define IPC_STAT 2
|
||||
#define IPC_SET 1 /* set options */
|
||||
#define IPC_STAT 2 /* get options */
|
||||
|
||||
/* Private key */
|
||||
#define IPC_PRIVATE 0
|
||||
#define IPC_PRIVATE (key_t)0
|
||||
|
||||
|
||||
struct ipc_perm {
|
||||
key_t key;
|
||||
key_t key; /* IPC identifier */
|
||||
uid_t uid; /* owner's user ID */
|
||||
gid_t gid; /* owner's group ID */
|
||||
uid_t cuid; /* creator's user ID */
|
||||
@@ -34,14 +34,10 @@ struct ipc_perm {
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
__BEGIN_DECLS
|
||||
|
||||
key_t ftok(const char *path, int id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _SYS_IPC_H */
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2008, Haiku Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _SYS_SEM_H
|
||||
#define _SYS_SEM_H
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
/* Semaphore operation flags */
|
||||
#define SEM_UNDO 10
|
||||
|
||||
/* Command definition for semctl */
|
||||
#define GETPID 3 /* Get process ID of last element manipulating */
|
||||
#define GETVAL 4 /* Get semval */
|
||||
#define GETALL 5 /* Get all semval */
|
||||
#define GETNCNT 6 /* Get semncnt */
|
||||
#define GETZCNT 7 /* Get semzcnt */
|
||||
#define SETVAL 8 /* Set semval */
|
||||
#define SETALL 9 /* Set all semval */
|
||||
|
||||
struct semid_ds {
|
||||
struct ipc_perm sem_perm; /* Operation permission structure */
|
||||
unsigned short sem_nsems; /* Number of semaphores in set */
|
||||
time_t sem_otime; /* Last semop */
|
||||
time_t sem_ctime; /* Last time changed by semctl */
|
||||
};
|
||||
|
||||
/* Structure passed as parameter to the semop function */
|
||||
struct sembuf {
|
||||
unsigned short sem_num; /* Semaphore number */
|
||||
short sem_op; /* Semaphore operation */
|
||||
short sem_flg; /* Operation flags */
|
||||
};
|
||||
|
||||
/*
|
||||
* Semaphore info structure. Useful for the ipcs
|
||||
* standard utily
|
||||
*/
|
||||
struct seminfo {
|
||||
int semmni; /* Number of semaphore identifies */
|
||||
int semmns; /* Number of semaphore in system */
|
||||
int semmnu; /* Number of undo structures in system */
|
||||
int semmsl; /* Max number of semaphores per id */
|
||||
int semopm; /* Max number of operations per semop call */
|
||||
int semume; /* Max number of undo entries per process */
|
||||
int semusz; /* Size in bytes of undo structure */
|
||||
int semvmx; /* Semaphore maximum valure */
|
||||
int semaem; /* adjust on exit max value */
|
||||
};
|
||||
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int semctl(int semID, int semNum, int command, ...);
|
||||
int semget(key_t key, int numSems, int semFlags);
|
||||
int semop(int semID, struct sembuf *semOps, size_t numSemOps);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _SYS_SEM_H */
|
||||
Reference in New Issue
Block a user