17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bdstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bdstevel@tonic-gate * (the "License").  You may not use this file except in compliance
77c478bdstevel@tonic-gate * with the License.
87c478bdstevel@tonic-gate *
97c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bdstevel@tonic-gate * See the License for the specific language governing permissions
127c478bdstevel@tonic-gate * and limitations under the License.
137c478bdstevel@tonic-gate *
147c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bdstevel@tonic-gate *
207c478bdstevel@tonic-gate * CDDL HEADER END
217c478bdstevel@tonic-gate */
2292ed178mike_s
237c478bdstevel@tonic-gate/*
2492ed178mike_s * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
2592ed178mike_s * Use is subject to license terms.
267c478bdstevel@tonic-gate */
277c478bdstevel@tonic-gate
287c478bdstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
297c478bdstevel@tonic-gate
307c478bdstevel@tonic-gate#include "gprof.h"
317c478bdstevel@tonic-gate
327c478bdstevel@tonic-gate/*
337c478bdstevel@tonic-gate *	these are the lists of names:
347c478bdstevel@tonic-gate *	there is the list head and then the listname
357c478bdstevel@tonic-gate *	is a pointer to the list head
367c478bdstevel@tonic-gate *	(for ease of passing to stringlist functions).
377c478bdstevel@tonic-gate */
387c478bdstevel@tonic-gatestruct stringlist	fhead = { 0, 0 };
397c478bdstevel@tonic-gatestruct stringlist	*flist = &fhead;
407c478bdstevel@tonic-gatestruct stringlist	Fhead = { 0, 0 };
417c478bdstevel@tonic-gatestruct stringlist	*Flist = &Fhead;
427c478bdstevel@tonic-gatestruct stringlist	ehead = { 0, 0 };
437c478bdstevel@tonic-gatestruct stringlist	*elist = &ehead;
447c478bdstevel@tonic-gatestruct stringlist	Ehead = { 0, 0 };
457c478bdstevel@tonic-gatestruct stringlist	*Elist = &Ehead;
467c478bdstevel@tonic-gate
477c478bdstevel@tonic-gatevoid
487c478bdstevel@tonic-gateaddlist(struct stringlist *listp, char *funcname)
497c478bdstevel@tonic-gate{
507c478bdstevel@tonic-gate	struct stringlist	*slp;
517c478bdstevel@tonic-gate
5292ed178mike_s	slp = malloc(sizeof (struct stringlist));
537c478bdstevel@tonic-gate
547c478bdstevel@tonic-gate	if (slp == NULL) {
5592ed178mike_s		(void) fprintf(stderr, "gprof: ran out room for printlist\n");
567c478bdstevel@tonic-gate		exit(1);
577c478bdstevel@tonic-gate	}
587c478bdstevel@tonic-gate
597c478bdstevel@tonic-gate	slp->next = listp->next;
607c478bdstevel@tonic-gate	slp->string = funcname;
617c478bdstevel@tonic-gate	listp->next = slp;
627c478bdstevel@tonic-gate}
637c478bdstevel@tonic-gate
647c478bdstevel@tonic-gatebool
657c478bdstevel@tonic-gateonlist(struct stringlist *listp, char *funcname)
667c478bdstevel@tonic-gate{
677c478bdstevel@tonic-gate	struct stringlist	*slp;
687c478bdstevel@tonic-gate
697c478bdstevel@tonic-gate	for (slp = listp->next; slp; slp = slp->next) {
707c478bdstevel@tonic-gate		if (strcmp(slp->string, funcname) == 0)
717c478bdstevel@tonic-gate			return (TRUE);
727c478bdstevel@tonic-gate
737c478bdstevel@tonic-gate		if (funcname[0] == '_' &&
747c478bdstevel@tonic-gate		    strcmp(slp->string, &funcname[1]) == 0)
757c478bdstevel@tonic-gate			return (TRUE);
767c478bdstevel@tonic-gate	}
777c478bdstevel@tonic-gate	return (FALSE);
787c478bdstevel@tonic-gate}
79