/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1994, by Sun Microsytems, Inc.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Includes
*/
#include "tnf_buf.h"
#include "tnf_types.h"
#include "tnf_trace.h"
/*
* Defines
*/
/*
* CAUTION: halfword_accessible assumes that the pointer is to a reclaimable
* block - i.e. negative offsets have a 0 in high bit
*/
#define HALFWORD_ACCESSIBLE(x) \
((((x) & 0xffff8000) == 0) || (((x) & 0xffff8000) == 0x7fff8000))
/*
* Check that x can be encoded in tagarg slot
* Same as above, but operates on ints (no space bit)
*/
#define TAGARG_CHECK(x) \
(((x) < 32767) && ((x) > -32768))
/*
* Check that hit 32 bits of hrtime are zero
*/
#define TIME_CHECK(x) \
(((x) >> 32) == 0)
/*
* CAUTION: Use the following macro only when doing a self relative pointer
* to a target in the same block
*/
/*
* Typedefs
*/
typedef struct {
/*
* Declarations
*/
/*
* tnf_trace_alloc
* the probe allocation function
*/
void *
{
/*
* Check the "tracing active" flag after setting the busy bit;
* this avoids a race in which we check the "tracing active"
* flag, then it gets turned off, and the buffer gets
* deallocated, before we've set the busy bit.
*/
return (NULL);
if (!tnf_tracing_active)
goto null_ret;
/*
* Write probe tag if needed
*/
if (probe_index == 0) {
goto null_ret;
}
/*
* Determine how much memory is required
*/
if (PROBE_IS_FILE_PTR(probe_index))
/* common case - probe_index is a file ptr */
/* LINTED assignment of 64-bit integer to 32-bit integer */
else
/* rare case -- get an extra fwd ptr */
asize += sizeof (tnf_ref32_t);
/*
* Allocate memory
*/
/* LINTED assignment of 64-bit integer to 16-bit integer */
goto null_ret;
/* LINTED pointer cast may result in improper alignment */
/*
* Check if the probe tag needs more work
*/
if (!PROBE_IS_FILE_PTR(probe_index)) {
/* use up first fwd ptr */
/* LINTED assignment of 64-bit integer to 32-bit integer */
/* LINTED cast from 64-bit integer to 32-bit integer */
fwd_p++;
}
/*
* Get timestamp
*/
/*
* Write schedule record if needed
*/
/* LINTED pointer cast */
/* No record written yet */
goto new_schedule;
/*
* Note: Don't bother about space bit here, because we'll
* only use bits 15:2 anyway
*/
#if defined(_LP64)
/* LINTED assignment of 64-bit integer to 32-bit integer */
#else
#endif
if (!TAGARG_CHECK(sched_offset))
/* Record too far away to reference */
goto new_schedule;
if (!TIME_CHECK(time_diff))
/* Time delta can't fit in 32 bits */
goto new_schedule;
/* CPU information is invalid */
goto new_schedule;
/*
* Can reuse existing schedule record
* Since we did not allocate any more space, can giveback
*/
#if defined(_LP64)
/* LINTED warning: assignment of 64-bit integer to 16-bit integer */
#else
#endif
/*
* Store return params and two common event members, return buffer
*/
#if defined(_LP64)
/* LINTED assignment of 64-bit integer to 32-bit integer */
#else
#endif
return (buffer);
/*
* Write a new schedule record for this thread
*/
time_diff = 0;
/* use one of the extra alloced words for the forwarding ptr */
#if defined(_LP64)
/* LINTED assignment of 64-bit integer to 32-bit integer */
/* LINTED */
/* LINTED cast from 64-bit integer to 32-bit integer */
#else
#endif
} else {
/* Allocation failed (tracing may have been stopped) */
sched_offset = 0;
}
goto good_ret;
/*
* Clear busy flag and return null
*/
return (NULL);
}
/*
* tnf_trace_commit
*/
void
{
/* commit reusable bytes */
/* commit tag bytes */
/* clear busy flag */
}
/*
* tnf_trace_rollback
*/
void
{
/* rollback data bytes */
/* commit tag bytes */
/* zap schedule record, since it is in uncommitted store */
/* clear busy flag */
}
/*
* tnf_allocate
* exported interface for allocating trace memory
*/
void *
{
}