- struct uprof *upp = &p->p_stats->p_prof, *upc;
- struct user_uprof *user_upp = NULL, *user_upc;
- int s;
- boolean_t is64bit = proc_is64bit(p);
-
- if (is64bit) {
- user_upp = &p->p_stats->user_p_prof;
- if (user_upp->pr_scale == 0)
- return (0);
- }
- else {
- if (upp->pr_scale == 0)
- return (0);
- }
-
- s = ml_set_interrupts_enabled(FALSE);
-
- if (is64bit) {
- user_upc = (struct user_uprof *) kalloc(sizeof (struct user_uprof));
- user_upc->pr_base = uap->bufbase;
- user_upc->pr_size = uap->bufsize;
- user_upc->pr_off = uap->pcoffset;
- user_upc->pr_scale = uap->pcscale;
- PROFILE_LOCK(&user_upp->pr_lock);
- user_upc->pr_next = user_upp->pr_next;
- user_upp->pr_next = user_upc;
- PROFILE_UNLOCK(&user_upp->pr_lock);
- }
- else {
- upc = (struct uprof *) kalloc(sizeof (struct uprof));
- upc->pr_base = CAST_DOWN(caddr_t, uap->bufbase);
- upc->pr_size = uap->bufsize;
- upc->pr_off = uap->pcoffset;
- upc->pr_scale = uap->pcscale;
- PROFILE_LOCK(&upp->pr_lock);
- upc->pr_next = upp->pr_next;
- upp->pr_next = upc;
- PROFILE_UNLOCK(&upp->pr_lock);
- }
-
- ml_set_interrupts_enabled(s);
- return(0);