]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/dev/dtrace/profile_prvd.c
xnu-7195.101.1.tar.gz
[apple/xnu.git] / bsd / dev / dtrace / profile_prvd.c
index 6d36e4cde7f72765b2bdc44e615ec507a45e89de..450a69f4b0c5aacfab619d97e69b2dacb3aae9af 100644 (file)
  * Use is subject to license terms.
  */
 
-/* #pragma ident       "@(#)profile.c  1.7     07/01/10 SMI" */
-
-#ifdef KERNEL
-#ifndef _KERNEL
-#define _KERNEL /* Solaris vs. Darwin */
-#endif
-#endif
-
 #include <kern/cpu_data.h>
 #include <kern/thread.h>
 #include <kern/assert.h>
@@ -324,9 +316,9 @@ profile_create(hrtime_t interval, const char *name, int kind)
                return;
        }
 
-       atomic_add_32(&profile_total, 1);
+       os_atomic_inc(&profile_total, relaxed);
        if (profile_total > profile_max) {
-               atomic_add_32(&profile_total, -1);
+               os_atomic_dec(&profile_total, relaxed);
                return;
        }
 
@@ -503,7 +495,7 @@ profile_destroy(void *arg, dtrace_id_t id, void *parg)
        }
 
        ASSERT(profile_total >= 1);
-       atomic_add_32(&profile_total, -1);
+       os_atomic_dec(&profile_total, relaxed);
 }
 
 /*ARGSUSED*/
@@ -719,26 +711,20 @@ _profile_open(dev_t dev, int flags, int devtype, struct proc *p)
 
 #define PROFILE_MAJOR  -24 /* let the kernel pick the device number */
 
-/*
- * A struct describing which functions will get invoked for certain
- * actions.
- */
-static struct cdevsw profile_cdevsw =
+static const struct cdevsw profile_cdevsw =
 {
-       _profile_open,          /* open */
-       eno_opcl,                       /* close */
-       eno_rdwrt,                      /* read */
-       eno_rdwrt,                      /* write */
-       eno_ioctl,                      /* ioctl */
-       (stop_fcn_t *)nulldev, /* stop */
-       (reset_fcn_t *)nulldev, /* reset */
-       NULL,                           /* tty's */
-       eno_select,                     /* select */
-       eno_mmap,                       /* mmap */
-       eno_strat,                      /* strategy */
-       eno_getc,                       /* getc */
-       eno_putc,                       /* putc */
-       0                                       /* type */
+       .d_open = _profile_open,
+       .d_close = eno_opcl,
+       .d_read = eno_rdwrt,
+       .d_write = eno_rdwrt,
+       .d_ioctl = eno_ioctl,
+       .d_stop = (stop_fcn_t *)nulldev,
+       .d_reset = (reset_fcn_t *)nulldev,
+       .d_select = eno_select,
+       .d_mmap = eno_mmap,
+       .d_strategy = eno_strat,
+       .d_reserved_1 = eno_getc,
+       .d_reserved_2 = eno_putc,
 };
 
 void