X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Fltt-types.h;h=015d3c3809586c42bd02c0eeceb9ef0ecb6eba0f;hb=ae3d0f50f89e7b965795a9b9ad7e1f533f760598;hp=a1701874d2dde097a98893b78c6e660f0eec34e1;hpb=e2858ae1861236182a54a00daaeaa7d2a0f8c2a8;p=lttv.git diff --git a/ltt/branches/poly/ltt/ltt-types.h b/ltt/branches/poly/ltt/ltt-types.h index a1701874..015d3c38 100644 --- a/ltt/branches/poly/ltt/ltt-types.h +++ b/ltt/branches/poly/ltt/ltt-types.h @@ -1,19 +1,19 @@ /* This file is part of the Linux Trace Toolkit viewer * Copyright (C) 2004-2005 Mathieu Desnoyers * - * 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 library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License Version 2.1 as published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, + * This library 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser 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. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifndef LTT_TYPES_H @@ -23,8 +23,9 @@ * */ #include -#include +//#include #include +#include /***************************************************************************** @@ -39,35 +40,52 @@ * ****************************************************************************/ -inline gint64 ltt_get_int64(LttTrace t, void *ptr) +static inline gint64 ltt_get_int64(gboolean reverse_byte_order, void *ptr) { - return (gint64) (t->reverse_byte_order ? GUINT64_SWAP_LE_BE(ptr): ptr); + guint64 value = *(guint64*)ptr; + return (gint64) (reverse_byte_order ? GUINT64_SWAP_LE_BE(value): value); } -inline guint64 ltt_get_uint64(LttTrace t, void *ptr) +static inline guint64 ltt_get_uint64(gboolean reverse_byte_order, void *ptr) { - return (guint64) (t->reverse_byte_order ? GUINT64_SWAP_LE_BE(ptr): ptr); + guint64 value = *(guint64*)ptr; + return (guint64) (reverse_byte_order ? GUINT64_SWAP_LE_BE(value): value); } -inline gint32 ltt_get_int32(LttTrace t, void *ptr) +static inline gint32 ltt_get_int32(gboolean reverse_byte_order, void *ptr) { - return (gint32) (t->reverse_byte_order ? GUINT32_SWAP_LE_BE(ptr): ptr); + guint32 value = *(guint32*)ptr; + return (gint32) (reverse_byte_order ? GUINT32_SWAP_LE_BE(value): value); } -inline guint32 ltt_get_uint32(LttTrace t, void *ptr) +static inline guint32 ltt_get_uint32(gboolean reverse_byte_order, void *ptr) { - return (guint32) (t->reverse_byte_order ? GUINT32_SWAP_LE_BE(ptr): ptr); + guint32 value = *(guint32*)ptr; + return (guint32) (reverse_byte_order ? GUINT32_SWAP_LE_BE(value): value); } -inline gint16 ltt_get_int16(LttTrace t, void *ptr) +static inline gint16 ltt_get_int16(gboolean reverse_byte_order, void *ptr) { - return (gint16) (t->reverse_byte_order ? GUINT16_SWAP_LE_BE(ptr): ptr); + guint16 value = *(guint16*)ptr; + return (gint16) (reverse_byte_order ? GUINT16_SWAP_LE_BE(value): value); } -inline guint16 ltt_get_uint16(LttTrace t, void *ptr) +static inline guint16 ltt_get_uint16(gboolean reverse_byte_order, void *ptr) { - return (guint16) (t->reverse_byte_order ? GUINT16_SWAP_LE_BE(ptr): ptr); + guint16 value = *(guint16*)ptr; + return (guint16) (reverse_byte_order ? GUINT16_SWAP_LE_BE(value): value); +} + +static inline LttTime ltt_get_time(gboolean reverse_byte_order, void *ptr) +{ + LttTime output; + + output.tv_sec = ltt_get_uint32(reverse_byte_order, ptr); + ptr += sizeof(guint32); + output.tv_nsec = ltt_get_uint32(reverse_byte_order, ptr); + + return output; } #endif // LTT_TYPES_H