| 1 | /* This file is part of the Linux Trace Toolkit viewer |
| 2 | * Copyright (C) 2004-2005 Mathieu Desnoyers |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License Version 2 as |
| 6 | * published by the Free Software Foundation; |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
| 16 | * MA 02111-1307, USA. |
| 17 | */ |
| 18 | |
| 19 | #ifndef LTT_TYPES_H |
| 20 | #define LTT_TYPES_H |
| 21 | |
| 22 | /* Set of functions to access the types portably, given the trace as parameter. |
| 23 | * */ |
| 24 | |
| 25 | #include <ltt/ltt.h> |
| 26 | #include <ltt/ltt-private.h> |
| 27 | #include <glib.h> |
| 28 | |
| 29 | |
| 30 | /***************************************************************************** |
| 31 | *Function name |
| 32 | * ltt_get_int64 : get a 64 bits integer number |
| 33 | *Input params |
| 34 | * ptr : pointer to the integer |
| 35 | *Return value |
| 36 | * gint64 : a 64 bits integer |
| 37 | * |
| 38 | * Takes care of endianness |
| 39 | * |
| 40 | ****************************************************************************/ |
| 41 | |
| 42 | inline gint64 ltt_get_int64(LttTrace t, void *ptr) |
| 43 | { |
| 44 | return (gint64) (t->reverse_byte_order ? GUINT64_SWAP_LE_BE(ptr): ptr); |
| 45 | } |
| 46 | |
| 47 | |
| 48 | inline guint64 ltt_get_uint64(LttTrace t, void *ptr) |
| 49 | { |
| 50 | return (guint64) (t->reverse_byte_order ? GUINT64_SWAP_LE_BE(ptr): ptr); |
| 51 | } |
| 52 | |
| 53 | inline gint32 ltt_get_int32(LttTrace t, void *ptr) |
| 54 | { |
| 55 | return (gint32) (t->reverse_byte_order ? GUINT32_SWAP_LE_BE(ptr): ptr); |
| 56 | } |
| 57 | |
| 58 | inline guint32 ltt_get_uint32(LttTrace t, void *ptr) |
| 59 | { |
| 60 | return (guint32) (t->reverse_byte_order ? GUINT32_SWAP_LE_BE(ptr): ptr); |
| 61 | } |
| 62 | |
| 63 | inline gint16 ltt_get_int16(LttTrace t, void *ptr) |
| 64 | { |
| 65 | return (gint16) (t->reverse_byte_order ? GUINT16_SWAP_LE_BE(ptr): ptr); |
| 66 | } |
| 67 | |
| 68 | inline guint16 ltt_get_uint16(LttTrace t, void *ptr) |
| 69 | { |
| 70 | return (guint16) (t->reverse_byte_order ? GUINT16_SWAP_LE_BE(ptr): ptr); |
| 71 | } |
| 72 | |
| 73 | #endif // LTT_TYPES_H |