/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/* Copyright (c) 1995, 1997 Apple Computer, Inc. All Rights Reserved */
/*
#ifndef _SYS_LOCK_H_
#define _SYS_LOCK_H_
-#ifdef KERNEL
-
-#include <kern/simple_lock.h>
-#include <kern/simple_lock_types.h>
-
-#if defined(simple_lock_init)
-#undef simple_lock_init
-#endif
-#define simple_lock_init(l) usimple_lock_init((l),0)
-
-#if defined(simple_lock)
-#undef simple_lock
-#endif
-#define simple_lock(l) ((void) 1)
-#if defined(simple_unlock)
-#undef simple_unlock
-#endif
-#define simple_unlock(l) ((void) 1)
+#include <sys/appleapiopts.h>
+#include <sys/types.h>
+#include <sys/cdefs.h>
-#if defined(simple_lock_try)
-#undef simple_lock_try
-#endif
-#define simple_lock_try(l) 1
-
-#else /* KERNEL */
-
-#ifndef _MACHINE_SIMPLE_LOCK_DATA_
-#define _MACHINE_SIMPLE_LOCK_DATA_
-
-#include <mach/boolean.h>
-
-#if defined(__ppc__)
-struct slock{
- volatile unsigned int lock_data[10];
-};
-#else
-struct slock{
- volatile unsigned int lock_data[9];
-};
-#endif
-typedef struct slock simple_lock_data_t;
-typedef struct slock *simple_lock_t;
-#define decl_simple_lock_data(class,name) \
-class simple_lock_data_t name;
+#ifdef KERNEL
-#endif /* _MACHINE_SIMPLE_LOCK_DATA_ */
+#include <kern/locks.h>
#endif /* KERNEL */
+
+#ifdef BSD_KERNEL_PRIVATE
/*
* The general lock structure. Provides for multiple shared locks,
* upgrading from shared to exclusive, and sleeping until the lock
* can be gained. The simple locks are defined in <machine/param.h>.
*/
struct lock__bsd__ {
- simple_lock_data_t
- lk_interlock; /* lock on remaining fields */
+ void * lk_interlock[10]; /* lock on remaining fields */
u_int lk_flags; /* see below */
int lk_sharecount; /* # of accepted shared locks */
int lk_waitcount; /* # of processes sleeping for lock */
short lk_exclusivecount; /* # of recursive exclusive locks */
short lk_prio; /* priority at which to sleep */
- char *lk_wmesg; /* resource sleeping (for tsleep) */
+ const char *lk_wmesg; /* resource sleeping (for tsleep) */
int lk_timo; /* maximum sleep time (for tsleep) */
pid_t lk_lockholder; /* pid of exclusive lock holder */
void *lk_lockthread; /* thread which acquired excl lock */
};
+
+// LP64todo - should this move?
+
+/* LP64 version of lock__bsd__. all pointers
+ * grow when we're dealing with a 64-bit process.
+ * WARNING - keep in sync with lock__bsd__
+ */
+
+struct user_lock__bsd__ {
+ user_addr_t lk_interlock[10]; /* lock on remaining fields */
+ u_int lk_flags; /* see below */
+ int lk_sharecount; /* # of accepted shared locks */
+ int lk_waitcount; /* # of processes sleeping for lock */
+ short lk_exclusivecount; /* # of recursive exclusive locks */
+ short lk_prio; /* priority at which to sleep */
+ user_addr_t lk_wmesg; /* resource sleeping (for tsleep) */
+ int lk_timo; /* maximum sleep time (for tsleep) */
+ pid_t lk_lockholder; /* pid of exclusive lock holder */
+ user_addr_t lk_lockthread; /* thread which acquired excl lock */
+};
+
/*
* Lock request types:
* LK_SHARED - get one of many possible shared locks. If a process
struct proc;
-void lockinit __P((struct lock__bsd__ *, int prio, char *wmesg, int timo,
- int flags));
-int lockmgr __P((struct lock__bsd__ *, u_int flags,
- simple_lock_t, struct proc *p));
-int lockstatus __P((struct lock__bsd__ *));
+void lockinit(struct lock__bsd__ *, int prio, const char *wmesg, int timo,
+ int flags);
+int lockmgr(struct lock__bsd__ *, u_int flags,
+ void *, struct proc *p);
+int lockstatus(struct lock__bsd__ *);
+
+#endif /* BSD_KERNEL_PRIVATE */
#endif /* _SYS_LOCK_H_ */