X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Fevent.c;h=bd9a8fbe9eeaded3edb9e8f218c1b0cde8d8df02;hb=96da5c0d83846884f7be822410209325a2dd0e51;hp=f762dbddf5d174e306175115682f4d94a8776444;hpb=dd691a2ef3d6fdcba001206bf686a4cdce26b545;p=lttv.git diff --git a/ltt/branches/poly/ltt/event.c b/ltt/branches/poly/ltt/event.c index f762dbdd..bd9a8fbe 100644 --- a/ltt/branches/poly/ltt/event.c +++ b/ltt/branches/poly/ltt/event.c @@ -1,3 +1,21 @@ +/* This file is part of the Linux Trace Toolkit viewer + * Copyright (C) 2003-2004 Xiangxiu Yang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License Version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + #include #include #include @@ -242,6 +260,66 @@ void ltt_event_position_set(LttEventPosition *ep, ep->event_num = index_in_block; } +/***************************************************************************** + * Function name + * ltt_event_position_compare : compare two positions + * Input params + * ep1 : a pointer to event's position structure + * ep2 : a pointer to event's position structure + * Return + * -1 is ep1 < ep2 + * 1 if ep1 > ep2 + * 0 if ep1 == ep2 + ****************************************************************************/ + + +gint ltt_event_position_compare(const LttEventPosition *ep1, + const LttEventPosition *ep2) +{ + if(ep1->tf != ep2->tf) + g_error("ltt_event_position_compare on different tracefiles makes no sense"); + if(ep1->block_num < ep2->block_num) + return -1; + if(ep1->block_num > ep2->block_num) + return 1; + if(ep1->event_num < ep2->event_num) + return -1; + if(ep1->event_num > ep2->event_num) + return 1; + return 0; +} + +/***************************************************************************** + * Function name + * ltt_event_event_position_compare : compare two positions, one in event, + * other in position opaque structure. + * Input params + * event : a pointer to event structure + * ep : a pointer to event's position structure + * Return + * -1 is event < ep + * 1 if event > ep + * 0 if event == ep + ****************************************************************************/ + +gint ltt_event_event_position_compare(const LttEvent *event, + const LttEventPosition *ep) +{ + if(event->tf != ep->tf) + g_error("ltt_event_position_compare on different tracefiles makes no sense"); + if(e->which_block < ep->block_num) + return -1; + if(e->which_block > ep->block_num) + return 1; + if(e->which_event < ep->event_num) + return -1; + if(e->which_event > ep->event_num) + return 1; + return 0; +} + + + /***************************************************************************** *Function name * ltt_event_cpu_i: get the cpu id where the event happens