/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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) 2008-2009, Intel Corporation.
* All Rights Reserved.
*/
#include <unistd.h>
#include <libintl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <procfs.h>
#include <fcntl.h>
#include "latencytop.h"
/* Pipe that breaks the event loop (and exits early) */
/*
* Get current system time in milliseconds (1e-3).
*/
lt_millisecond(void)
{
struct timeval p;
(void) gettimeofday(&p, NULL);
}
/*
* Check if we are out of memory.
*/
void
lt_check_null(void *p)
{
if (p == NULL) {
g_assert(0);
exit(2);
}
}
/*
* Safe malloc.
*/
void *
{
return (ret);
}
/*
* Safe alloc with memory cleared.
* It is named "zalloc" because its signature is different from
* calloc() in stdlib.
*/
void *
{
return (ret);
}
/*
* Safe strdup.
*/
char *
{
return (ret);
}
/*
* Get string for current time, e.g. YYYY-MM-DD
*/
void
{
time_t t;
int i;
(void) time(&t);
buffer[i] = '\0';
} else {
break;
}
}
}
/*
* Retrieves the process's executable name and arguments from /proc.
*/
char *
{
int fd;
int ret;
if (fd == -1) {
return (NULL);
}
if (ret < 0) {
return (NULL);
}
switch (field) {
case LT_FIELD_FNAME:
case LT_FIELD_PSARGS:
}
return (NULL);
}
/*
* Helper function to update the data structure.
*/
void
{
switch (type) {
case LT_STAT_COUNT:
break;
case LT_STAT_SUM:
break;
case LT_STAT_MAX:
}
break;
default:
break;
}
}
/*
* Helper function to sort on total.
*/
int
{
/*
* lt_s_total is of type int64_t, so we can't simply return
* (b->lt_se_data.lt_s_total - a->lt_se_data.lt_s_total).
*/
return (1);
return (-1);
} else {
return (0);
}
}
/*
* Helper function to sort on max.
*/
int
{
return (1);
return (-1);
} else {
return (0);
}
}
/*
* Helper function to sort on count.
*/
int
{
return (1);
return (-1);
} else {
return (0);
}
}
/*
* Helper function to sort on average.
*/
int
{
return (1);
return (-1);
} else {
return (0);
}
}
/*
* Create pipe for signal handler and wakeup.
*/
void
lt_gpipe_init(void)
{
(void) pipe(signal_pipe);
}
/*
* Close the pipe used in signal handler.
*/
void
lt_gpipe_deinit(void)
{
(void) close(signal_pipe[0]);
}
/*
* Break early from the main loop.
*/
void
{
}
int
lt_gpipe_readfd(void)
{
return (signal_pipe[0]);
}
/*
* Check if the given file exists.
*/
int
{
return (1);
} else {
return (0);
}
}