PERFORCE change 76163 for review
Robert Watson
rwatson at FreeBSD.org
Thu Apr 28 22:46:52 GMT 2005
http://perforce.freebsd.org/chv.cgi?CH=76163
Change 76163 by rwatson at rwatson_paprika on 2005/04/28 22:46:32
Slight POSIX semaphore cleanups before larger cleanup.
Affected files ...
.. //depot/projects/trustedbsd/mac/sys/kern/uipc_sem.c#23 edit
Differences ...
==== //depot/projects/trustedbsd/mac/sys/kern/uipc_sem.c#23 (text+ko) ====
@@ -54,13 +54,11 @@
#include <sys/sysent.h>
#include <sys/sysctl.h>
#include <sys/time.h>
+#include <sys/mac.h>
#include <sys/malloc.h>
#include <sys/fcntl.h>
-#ifdef MAC
-#include <sys/mac.h>
+
#include <posix4/ksem.h>
-#endif
-
#include <posix4/posix4.h>
#include <posix4/semaphore.h>
#include <posix4/_semaphore.h>
@@ -68,7 +66,7 @@
static int sem_count_proc(struct proc *p);
static struct ksem *sem_lookup_byname(const char *name);
static int sem_create(struct thread *td, const char *name,
-struct ksem **ksret, mode_t mode, unsigned int value);
+ struct ksem **ksret, mode_t mode, unsigned int value);
static void sem_free(struct ksem *ksnew, int checkrefs);
static int sem_perm(struct thread *td, struct ksem *ks);
static void sem_enter(struct proc *p, struct ksem *ks);
@@ -109,32 +107,6 @@
SEM_FREE((ksem)); \
} while (0)
-#ifndef MAC
-struct kuser {
- pid_t ku_pid;
- LIST_ENTRY(kuser) ku_next;
-};
-
-struct ksem {
- LIST_ENTRY(ksem) ks_entry; /* global list entry */
- int ks_onlist; /* boolean if on a list (ks_entry) */
- char *ks_name; /* if named, this is the name */
- int ks_ref; /* number of references */
- mode_t ks_mode; /* protection bits */
- uid_t ks_uid; /* creator uid */
- gid_t ks_gid; /* creator gid */
- unsigned int ks_value; /* current value */
- struct cv ks_cv; /* waiters sleep here */
- int ks_waiters; /* number of waiters */
- LIST_HEAD(, kuser) ks_users; /* pids using this sem */
- struct mtx ks_mtx; /* mutex protecting this semaphore */
- int ks_unlinked; /* Whether the named sem is unlinked */
-};
-#else
-struct kuser;
-struct ksem;
-#endif
-
/*
* available semaphores go here, this includes sem_init and any semaphores
* created via sem_open that have not yet been unlinked.
@@ -150,9 +122,6 @@
static eventhandler_tag sem_exit_tag, sem_exec_tag, sem_fork_tag;
-#ifndef SEM_DEBUG
-#define SEM_DEBUG
-#endif
#ifdef SEM_DEBUG
#define DP(x) printf x
#else
@@ -163,6 +132,7 @@
void
sem_ref(struct ksem *ks)
{
+
mtx_assert(&sem_lock, MA_OWNED);
ks->ks_ref++;
DP(("sem_ref: ks = %p, ref = %d\n", ks, ks->ks_ref));
@@ -924,7 +894,9 @@
val = ks->ks_value;
mtx_unlock(&ks->ks_mtx);
error = copyout(&val, uap->val, sizeof(val));
+#ifdef MAC
err_getvalue:
+#endif
mtx_lock(&sem_lock);
REF_DOWN(ks);
mtx_unlock(&sem_lock);
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message
More information about the trustedbsd-cvs
mailing list