]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/sys/lock.h
xnu-792.1.5.tar.gz
[apple/xnu.git] / bsd / sys / lock.h
index 0e9783854c1dd95c4b7146b61e79f41b533ad166..5364f66e1f89af0dc85109be661bc337705baa82 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
 
 #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)
+#include <sys/appleapiopts.h>
+#include <sys/types.h>
+#include <sys/cdefs.h>
 
-#else /* KERNEL */
+#ifdef KERNEL
 
-#ifndef        _MACHINE_SIMPLE_LOCK_DATA_
-#define        _MACHINE_SIMPLE_LOCK_DATA_
+#include <kern/locks.h>
 
-#include <mach/boolean.h>
 
-#if defined(__ppc__)
-struct slock{
-       volatile unsigned int lock_data[10];
-};
-#else
-struct slock{
-       volatile unsigned int lock_data[9];
-};
+#if defined(thread_sleep_simple_lock)
+#undef thread_sleep_simple_lock
 #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;
+#define thread_sleep_simple_lock(l, e, i) thread_sleep_funnel((e), (i))
 
-#endif /* _MACHINE_SIMPLE_LOCK_DATA_ */
 
 #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__
+ */
+
+#if __DARWIN_ALIGN_NATURAL
+#pragma options align=natural
+#endif
+
+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 */
+};
+
+#if __DARWIN_ALIGN_NATURAL
+#pragma options align=reset
+#endif
+
 /*
  * Lock request types:
  *   LK_SHARED - get one of many possible shared locks. If a process
@@ -211,10 +224,12 @@ struct lock__bsd__ {
 
 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_ */