From cbd41522fece37839f38aaf3372b8a11fac9b267 Mon Sep 17 00:00:00 2001 From: yangxx Date: Thu, 30 Oct 2003 21:27:49 +0000 Subject: [PATCH] get rid of LTTTypes.h git-svn-id: http://ltt.polymtl.ca/svn@328 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/include/ltt/LTTTypes.h | 142 -------------------- ltt/branches/poly/include/ltt/Makefile.am | 1 - ltt/branches/poly/include/ltt/ltt-private.h | 20 +-- ltt/branches/poly/include/ltt/ltt.h | 4 +- ltt/branches/poly/ltt/event.c | 97 ++++++++----- ltt/branches/poly/ltt/facility.c | 1 - ltt/branches/poly/ltt/tracefile.c | 33 +++-- ltt/branches/poly/ltt/type.c | 1 - ltt/branches/poly/lttv/modules/guiEvents.c | 4 +- 9 files changed, 97 insertions(+), 206 deletions(-) delete mode 100644 ltt/branches/poly/include/ltt/LTTTypes.h diff --git a/ltt/branches/poly/include/ltt/LTTTypes.h b/ltt/branches/poly/include/ltt/LTTTypes.h deleted file mode 100644 index d33bf1b5..00000000 --- a/ltt/branches/poly/include/ltt/LTTTypes.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * LTTTypes.h - * - * Copyright (C) 2000 Karim Yaghmour (karym@opersys.com). - * - * This is distributed under GPL. - * - * Header for LTT-secific types. - * - * History : - * K.Y. 07/09/2001, Added David Schleef's architecture independent ltt_set_bit/ltt_clear_bit/ltt_test_bit - * JAL, 05/01/2001, Modified PPC bit manipulation functions for x86 compatibility. - * (andy_lowe@mvista.com) - * K.Y., 31/05/2000, Initial typing. - */ - -#ifndef __TRACE_TOOLKIT_TYPES_HEADER__ -#define __TRACE_TOOLKIT_TYPES_HEADER__ - -#include -#include - -#if defined(sun) - -typedef unsigned char u_int8_t; -typedef unsigned short u_int16_t; -typedef unsigned int u_int32_t; -#ifdef _LP64 -typedef unsigned long u_int64_t; -#else /* _ILP32 */ -#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG) -typedef unsigned long long u_int64_t; -#endif /* __STDC__ - 0 == 0 && !defined(_NO_LONGLONG) */ -#endif /* _LP64 */ - -#endif /* defined(sun) */ - -extern __inline__ int ltt_set_bit(int nr, void * addr) -{ - unsigned char *p = addr; - unsigned char mask = 1 << (nr&7); - unsigned char old; - - p += nr>>3; - old = *p; - *p |= mask; - - return ((old & mask) != 0); -} - -extern __inline__ int ltt_clear_bit(int nr, void * addr) -{ - unsigned char *p = addr; - unsigned char mask = 1 << (nr&7); - unsigned char old; - - p += nr>>3; - old = *p; - *p &= ~mask; - - return ((old & mask) != 0); -} - -extern __inline__ int ltt_test_bit(int nr,void *addr) -{ - unsigned char *p = addr; - unsigned char mask = 1 << (nr&7); - - p += nr>>3; - - return ((*p & mask) != 0); -} - -/* Big-endian/little-endian conversion macros for cross-development. */ -#if TARGET_NATIVE -/* For native development, these conversion macros aren't needed. */ -#define BREV16(x) (x) -#define BREV32(x) (x) -#define BREV64(x) (x) -#define RFT8(db,x) (x) -#define RFT16(db,x) (x) -#define RFT32(db,x) (x) -#define RFT64(db,x) (x) - -/* Non-native development */ -#else - /* BREV16: byte-reverse a 16-bit integer */ -#define BREV16(x) ((((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8)) - /* BREV32: byte-reverse a 32-bit integer */ -#define BREV32(x) ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) \ - | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) - /* BREV64: byte-reverse a 64-bit integer */ -#define BREV64(x) ((((x) & 0xff00000000000000) >> 56) \ - | (((x) & 0x00ff000000000000) >> 40) \ - | (((x) & 0x0000ff0000000000) >> 24) \ - | (((x) & 0x000000ff00000000) >> 8) \ - | (((x) & 0x00000000ff000000) << 8) \ - | (((x) & 0x0000000000ff0000) << 24) \ - | (((x) & 0x000000000000ff00) << 40) \ - | (((x) & 0x00000000000000ff) << 56)) - /* RFTn: Read From Trace - * Conditionally byte-reverse an 8-, 16-, 32-, or 64-bit integer - * based on the value of the ByteRev member of the trace database - * structure pointer passed as the first argument.. - */ -#define RFT8(db,x) (x) -#define RFT16(db,x) ((db)->ByteRev ? BREV16(x) : (x)) -#define RFT32(db,x) ((db)->ByteRev ? BREV32(x) : (x)) -#define RFT64(db,x) ((db)->ByteRev ? BREV64(x) : (x)) -#endif /* TRACE_TARGET_NATIVE */ - -#if !defined(sun) -/* Some type corrections, just in case */ -#ifndef uint8_t -#define uint8_t u_int8_t -#endif -#ifndef uint16_t -#define uint16_t u_int16_t -#endif -#ifndef uint32_t -#define uint32_t u_int32_t -#endif -#ifndef uint64_t -#define uint64_t u_int64_t -#endif -#endif /* !defined(sun) */ - -/* Structure packing */ -#if LTT_UNPACKED_STRUCTS -#define LTT_PACKED_STRUCT -#else -#define LTT_PACKED_STRUCT __attribute__ ((packed)) -#endif /* UNPACKED_STRUCTS */ - -/* Trace mask */ -typedef uint64_t trace_event_mask; - -/* Boolean stuff */ /* Now in glib */ -//#define TRUE 1 -//#define FALSE 0 - -#endif /* __TRACE_TOOLKIT_TYPES_HEADER__ */ diff --git a/ltt/branches/poly/include/ltt/Makefile.am b/ltt/branches/poly/include/ltt/Makefile.am index be3e9f10..70065316 100644 --- a/ltt/branches/poly/include/ltt/Makefile.am +++ b/ltt/branches/poly/include/ltt/Makefile.am @@ -1,5 +1,4 @@ lttinclude_HEADERS = \ - LTTTypes.h\ event.h\ facility.h\ ltt-private.h\ diff --git a/ltt/branches/poly/include/ltt/ltt-private.h b/ltt/branches/poly/include/ltt/ltt-private.h index c516bb49..faf2baff 100644 --- a/ltt/branches/poly/include/ltt/ltt-private.h +++ b/ltt/branches/poly/include/ltt/ltt-private.h @@ -2,11 +2,13 @@ #define LTT_PRIVATE_H #include +#include #include -#include #include #include +#define LTT_PACKED_STRUCT __attribute__ ((packed)) + /* enumeration definition */ typedef enum _BuildinEvent{ @@ -22,19 +24,19 @@ typedef enum _BuildinEvent{ typedef struct _FacilityLoad{ char * name; LttChecksum checksum; - uint32_t base_code; + guint32 base_code; } LTT_PACKED_STRUCT FacilityLoad; typedef struct _BlockStart { LttTime time; //Time stamp of this block LttCycleCount cycle_count; //cycle count of the event - uint32_t block_id; //block id + guint32 block_id; //block id } LTT_PACKED_STRUCT BlockStart; typedef struct _BlockEnd { LttTime time; //Time stamp of this block LttCycleCount cycle_count; //cycle count of the event - uint32_t block_id; //block id + guint32 block_id; //block id } LTT_PACKED_STRUCT BlockEnd; typedef struct _TimeHeartbeat { @@ -97,8 +99,8 @@ struct _LttField{ }; struct _LttEvent{ - uint16_t event_id; - uint32_t time_delta; + guint16 event_id; + guint32 time_delta; LttTime event_time; LttCycleCount event_cycle_count; LttTracefile * tracefile; @@ -111,7 +113,7 @@ struct _LttFacility{ char * name; //facility name int event_number; //number of events in the facility LttChecksum checksum; //checksum of the facility - uint32_t base_id; //base id of the facility + guint32 base_id; //base id of the facility LttEventType ** events; //array of event types LttType ** named_types; int named_types_number; @@ -171,8 +173,8 @@ struct _LttEventPosition{ /***************************************************************************** macro for size of some data types *****************************************************************************/ -#define EVENT_ID_SIZE sizeof(uint16_t) -#define TIME_DELTA_SIZE sizeof(uint32_t) +#define EVENT_ID_SIZE sizeof(guint16) +#define TIME_DELTA_SIZE sizeof(guint32) #define EVENT_HEADER_SIZE (EVENT_ID_SIZE + TIME_DELTA_SIZE) diff --git a/ltt/branches/poly/include/ltt/ltt.h b/ltt/branches/poly/include/ltt/ltt.h index a5f3fee0..9e14dece 100644 --- a/ltt/branches/poly/include/ltt/ltt.h +++ b/ltt/branches/poly/include/ltt/ltt.h @@ -2,7 +2,7 @@ #define LTT_H #include -#include +#include /* A trace is associated with a tracing session run on a single, possibly multi-cpu, system. It is defined as a pathname to a directory containing @@ -83,7 +83,7 @@ typedef struct _TimeInterval{ } TimeInterval; -typedef uint64_t LttCycleCount; +typedef guint64 LttCycleCount; /* Event positions are used to seek within a tracefile based on diff --git a/ltt/branches/poly/ltt/event.c b/ltt/branches/poly/ltt/event.c index 46333ffb..9b3ff0d9 100644 --- a/ltt/branches/poly/ltt/event.c +++ b/ltt/branches/poly/ltt/event.c @@ -1,7 +1,6 @@ #include #include #include -#include #include "parser.h" #include @@ -337,17 +336,26 @@ unsigned ltt_event_get_unsigned(LttEvent *e, LttField *f) g_error("The type of the field is not unsigned int\n"); if(f->field_size == 1){ - uint8_t x = *(uint8_t*)(e->data + f->offset_root); + guint8 x = *(guint8 *)(e->data + f->offset_root); return (unsigned int) x; }else if(f->field_size == 2){ - uint16_t x = *(uint16_t*)(e->data + f->offset_root); - return (unsigned int) (revFlag ? BREV16(x): x); + guint16 x = *(guint16 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (unsigned int) (revFlag ? GUINT16_FROM_BE(x): x); + else + return (unsigned int) (revFlag ? GUINT16_FROM_LE(x): x); }else if(f->field_size == 4){ - uint32_t x = *(uint32_t*)(e->data + f->offset_root); - return (unsigned int) (revFlag ? BREV32(x): x); + guint32 x = *(guint32 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (unsigned int) (revFlag ? GUINT32_FROM_BE(x): x); + else + return (unsigned int) (revFlag ? GUINT32_FROM_LE(x): x); }else if(f->field_size == 8){ - uint64_t x = *(uint64_t*)(e->data + f->offset_root); - return (unsigned int) (revFlag ? BREV64(x): x); + guint64 x = *(guint64 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (unsigned int) (revFlag ? GUINT64_FROM_BE(x): x); + else + return (unsigned int) (revFlag ? GUINT64_FROM_LE(x): x); } } @@ -360,17 +368,26 @@ int ltt_event_get_int(LttEvent *e, LttField *f) g_error("The type of the field is not int\n"); if(f->field_size == 1){ - int8_t x = *(int8_t*)(e->data + f->offset_root); + gint8 x = *(gint8 *)(e->data + f->offset_root); return (int) x; }else if(f->field_size == 2){ - int16_t x = *(int16_t*)(e->data + f->offset_root); - return (int) (revFlag ? BREV16(x): x); + gint16 x = *(gint16 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (int) (revFlag ? GINT16_FROM_BE(x): x); + else + return (int) (revFlag ? GINT16_FROM_LE(x): x); }else if(f->field_size == 4){ - int32_t x = *(int32_t*)(e->data + f->offset_root); - return (int) (revFlag ? BREV32(x): x); + gint32 x = *(gint32 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (int) (revFlag ? GINT32_FROM_BE(x): x); + else + return (int) (revFlag ? GINT32_FROM_LE(x): x); }else if(f->field_size == 8){ - int64_t x = *(int64_t*)(e->data + f->offset_root); - return (int) (revFlag ? BREV64(x): x); + gint64 x = *(gint64 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (int) (revFlag ? GINT64_FROM_BE(x): x); + else + return (int) (revFlag ? GINT64_FROM_LE(x): x); } } @@ -384,17 +401,26 @@ unsigned long ltt_event_get_long_unsigned(LttEvent *e, LttField *f) g_error("The type of the field is not unsigned long\n"); if(f->field_size == 1){ - uint8_t x = *(uint8_t*)(e->data + f->offset_root); + guint8 x = *(guint8 *)(e->data + f->offset_root); return (unsigned long) x; }else if(f->field_size == 2){ - uint16_t x = *(uint16_t*)(e->data + f->offset_root); - return (unsigned long) (revFlag ? BREV16(x): x); + guint16 x = *(guint16 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (unsigned long) (revFlag ? GUINT16_FROM_BE(x): x); + else + return (unsigned long) (revFlag ? GUINT16_FROM_LE(x): x); }else if(f->field_size == 4){ - uint32_t x = *(uint32_t*)(e->data + f->offset_root); - return (unsigned long) (revFlag ? BREV32(x): x); + guint32 x = *(guint32 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (unsigned long) (revFlag ? GUINT32_FROM_BE(x): x); + else + return (unsigned long) (revFlag ? GUINT32_FROM_LE(x): x); }else if(f->field_size == 8){ - uint64_t x = *(uint64_t*)(e->data + f->offset_root); - return (unsigned long) (revFlag ? BREV64(x): x); + guint64 x = *(guint64 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (unsigned long) (revFlag ? GUINT64_FROM_BE(x): x); + else + return (unsigned long) (revFlag ? GUINT64_FROM_LE(x): x); } } @@ -407,17 +433,26 @@ long int ltt_event_get_long_int(LttEvent *e, LttField *f) g_error("The type of the field is not long int\n"); if(f->field_size == 1){ - int8_t x = *(int8_t*)(e->data + f->offset_root); + gint8 x = *(gint8 *)(e->data + f->offset_root); return (long) x; }else if(f->field_size == 2){ - int16_t x = *(int16_t*)(e->data + f->offset_root); - return (long) (revFlag ? BREV16(x): x); + gint16 x = *(gint16 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (long) (revFlag ? GINT16_FROM_BE(x): x); + else + return (long) (revFlag ? GINT16_FROM_LE(x): x); }else if(f->field_size == 4){ - int32_t x = *(int32_t*)(e->data + f->offset_root); - return (long) (revFlag ? BREV32(x): x); + gint32 x = *(gint32 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (long) (revFlag ? GINT32_FROM_BE(x): x); + else + return (long) (revFlag ? GINT32_FROM_LE(x): x); }else if(f->field_size == 8){ - int64_t x = *(int64_t*)(e->data + f->offset_root); - return (long) (revFlag ? BREV64(x): x); + gint64 x = *(gint64 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (long) (revFlag ? GINT64_FROM_BE(x): x); + else + return (long) (revFlag ? GINT64_FROM_LE(x): x); } } @@ -432,7 +467,7 @@ float ltt_event_get_float(LttEvent *e, LttField *f) if(revFlag == 0) return *(float *)(e->data + f->offset_root); else{ - uint32_t aInt; + guint32 aInt; memcpy((void*)&aInt, e->data + f->offset_root, 4); aInt = ___swab32(aInt); return *((float*)&aInt); @@ -450,7 +485,7 @@ double ltt_event_get_double(LttEvent *e, LttField *f) if(revFlag == 0) return *(double *)(e->data + f->offset_root); else{ - uint64_t aInt; + guint64 aInt; memcpy((void*)&aInt, e->data + f->offset_root, 8); aInt = ___swab64(aInt); return *((double *)&aInt); diff --git a/ltt/branches/poly/ltt/facility.c b/ltt/branches/poly/ltt/facility.c index 3cd638d5..6d70d572 100644 --- a/ltt/branches/poly/ltt/facility.c +++ b/ltt/branches/poly/ltt/facility.c @@ -2,7 +2,6 @@ #include #include -#include #include "parser.h" #include diff --git a/ltt/branches/poly/ltt/tracefile.c b/ltt/branches/poly/ltt/tracefile.c index 6186fc2c..ba8981e9 100644 --- a/ltt/branches/poly/ltt/tracefile.c +++ b/ltt/branches/poly/ltt/tracefile.c @@ -5,7 +5,6 @@ #include #include -#include #include "parser.h" #include @@ -108,7 +107,7 @@ void ltt_tracefile_open_control(LttTrace *t, char * control_name) LttTracefile * tf; LttEvent * ev; LttFacility * f; - uint16_t evId; + guint16 evId; void * pos; FacilityLoad fLoad; int i; @@ -128,7 +127,7 @@ void ltt_tracefile_open_control(LttTrace *t, char * control_name) pos = ev->data; fLoad.name = (char*)pos; fLoad.checksum = *(LttChecksum*)(pos + strlen(fLoad.name)); - fLoad.base_code = *(uint32_t*)(pos + strlen(fLoad.name) + sizeof(LttChecksum)); + fLoad.base_code = *(guint32 *)(pos + strlen(fLoad.name) + sizeof(LttChecksum)); for(i=0;ifacility_number;i++){ f = (LttFacility*)g_ptr_array_index(t->facilities,i); @@ -856,14 +855,14 @@ LttEvent *ltt_tracefile_read(LttTracefile *t) if(err)g_error("Can not read tracefile"); } - lttEvent->event_id = (int)(*(uint16_t *)(t->cur_event_pos)); + lttEvent->event_id = (int)(*(guint16 *)(t->cur_event_pos)); if(lttEvent->event_id == TRACE_TIME_HEARTBEAT) t->cur_heart_beat_number++; t->prev_event_time = t->current_event_time; // t->current_event_time = getEventTime(t); - lttEvent->time_delta = *(uint32_t*)(t->cur_event_pos + EVENT_ID_SIZE); + lttEvent->time_delta = *(guint32 *)(t->cur_event_pos + EVENT_ID_SIZE); lttEvent->event_time = t->current_event_time; lttEvent->tracefile = t; @@ -919,7 +918,7 @@ int readFile(int fd, void * buf, size_t size, char * mesg) int readBlock(LttTracefile * tf, int whichBlock) { off_t nbBytes; - uint32_t lostSize; + guint32 lostSize; if(whichBlock - tf->which_block == 1 && tf->which_block != 0){ tf->prev_block_end_time = tf->a_block_end->time; @@ -938,7 +937,7 @@ int readBlock(LttTracefile * tf, int whichBlock) return EIO; tf->a_block_start=(BlockStart *) (tf->buffer + EVENT_HEADER_SIZE); - lostSize = *(uint32_t*)(tf->buffer + tf->block_size - sizeof(uint32_t)); + lostSize = *(guint32 *)(tf->buffer + tf->block_size - sizeof(guint32)); tf->a_block_end=(BlockEnd *)(tf->buffer + tf->block_size - lostSize + EVENT_HEADER_SIZE); tf->last_event_pos = tf->buffer + tf->block_size - lostSize; @@ -991,7 +990,7 @@ int skipEvent(LttTracefile * t) LttEventType * evT; LttField * rootFld; - evId = (int)(*(uint16_t *)(t->cur_event_pos)); + evId = (int)(*(guint16 *)(t->cur_event_pos)); evData = t->cur_event_pos + EVENT_HEADER_SIZE; evT = ltt_trace_eventtype_get(t->trace,(unsigned)evId); @@ -1066,12 +1065,12 @@ LttTime getEventTime(LttTracefile * tf) LttCycleCount lEventTotalCycle; // Total cycles from start for event double lEventNSec; // Total usecs from start for event LttTime lTimeOffset; // Time offset in struct LttTime - uint16_t evId; - int64_t nanoSec, tmpCycleCount = (((uint64_t)1)<<32); + guint16 evId; + gint64 nanoSec, tmpCycleCount = (((guint64)1)<<32); static LttCycleCount preCycleCount = 0; static int count = 0; - evId = *(uint16_t*)tf->cur_event_pos; + evId = *(guint16 *)tf->cur_event_pos; if(evId == TRACE_BLOCK_START){ count = 0; preCycleCount = 0; @@ -1085,7 +1084,7 @@ LttTime getEventTime(LttTracefile * tf) } // Calculate total time in cycles from start of buffer for this event - cycle_count = (LttCycleCount)*(uint32_t*)(tf->cur_event_pos + EVENT_ID_SIZE); + cycle_count = (LttCycleCount)*(guint32 *)(tf->cur_event_pos + EVENT_ID_SIZE); if(cycle_count < preCycleCount)count++; preCycleCount = cycle_count; @@ -1273,11 +1272,11 @@ int getFieldtypeSize(LttTracefile * t, LttEventType * evT, int offsetRoot, int getIntNumber(int size, void *evD) { - int64_t i; - if(size == 1) i = *(int8_t *)evD; - else if(size == 2) i = *(int16_t *)evD; - else if(size == 4) i = *(int32_t *)evD; - else if(size == 8) i = *(int64_t *)evD; + gint64 i; + if(size == 1) i = *(gint8 *)evD; + else if(size == 2) i = *(gint16 *)evD; + else if(size == 4) i = *(gint32 *)evD; + else if(size == 8) i = *(gint64 *)evD; return (int) i; } diff --git a/ltt/branches/poly/ltt/type.c b/ltt/branches/poly/ltt/type.c index a2c73f22..be96a3c7 100644 --- a/ltt/branches/poly/ltt/type.c +++ b/ltt/branches/poly/ltt/type.c @@ -1,6 +1,5 @@ #include -#include #include "parser.h" #include diff --git a/ltt/branches/poly/lttv/modules/guiEvents.c b/ltt/branches/poly/lttv/modules/guiEvents.c index bd5668c3..ca7cd135 100644 --- a/ltt/branches/poly/lttv/modules/guiEvents.c +++ b/ltt/branches/poly/lttv/modules/guiEvents.c @@ -1164,10 +1164,10 @@ gboolean update_current_time(void * hook_data, void * call_data) { EventViewerData *event_viewer_data = (EventViewerData*) hook_data; event_viewer_data->current_time = *(LttTime*)call_data; - uint64_t nsec = event_viewer_data->current_time.tv_sec * NANOSECONDS_PER_SECOND + guint64 nsec = event_viewer_data->current_time.tv_sec * NANOSECONDS_PER_SECOND + event_viewer_data->current_time.tv_nsec; GtkTreeIter iter; - uint64_t time; + guint64 time; int count = 0; GtkTreeModel* model = (GtkTreeModel*)event_viewer_data->store_m; -- 2.34.1