1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2004-2005 Mathieu Desnoyers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License Version 2.1 as published by the Free Software Foundation.
8 * This library 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 GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 * Boston, MA 02111-1307, USA.
22 /* Set of functions to access the types portably, given the trace as parameter.
30 /*****************************************************************************
32 * ltt_get_int64 : get a 64 bits integer number
34 * ptr : pointer to the integer
36 * gint64 : a 64 bits integer
38 * Takes care of endianness
40 ****************************************************************************/
42 static inline gint64
ltt_get_int64(gboolean reverse_byte_order
, void *ptr
)
44 guint64 value
= *(guint64
*)ptr
;
45 return (gint64
) (reverse_byte_order
? GUINT64_SWAP_LE_BE(value
): value
);
49 static inline guint64
ltt_get_uint64(gboolean reverse_byte_order
, void *ptr
)
51 guint64 value
= *(guint64
*)ptr
;
52 return (guint64
) (reverse_byte_order
? GUINT64_SWAP_LE_BE(value
): value
);
55 static inline gint32
ltt_get_int32(gboolean reverse_byte_order
, void *ptr
)
57 guint32 value
= *(guint32
*)ptr
;
58 return (gint32
) (reverse_byte_order
? GUINT32_SWAP_LE_BE(value
): value
);
61 static inline guint32
ltt_get_uint32(gboolean reverse_byte_order
, void *ptr
)
63 guint32 value
= *(guint32
*)ptr
;
64 return (guint32
) (reverse_byte_order
? GUINT32_SWAP_LE_BE(value
): value
);
67 static inline gint16
ltt_get_int16(gboolean reverse_byte_order
, void *ptr
)
69 guint16 value
= *(guint16
*)ptr
;
70 return (gint16
) (reverse_byte_order
? GUINT16_SWAP_LE_BE(value
): value
);
73 static inline guint16
ltt_get_uint16(gboolean reverse_byte_order
, void *ptr
)
75 guint16 value
= *(guint16
*)ptr
;
76 return (guint16
) (reverse_byte_order
? GUINT16_SWAP_LE_BE(value
): value
);
79 static inline LttTime
ltt_get_time(gboolean reverse_byte_order
, void *ptr
)
83 output
.tv_sec
= ltt_get_uint32(reverse_byte_order
, ptr
);
84 ptr
+= sizeof(guint32
);
85 output
.tv_nsec
= ltt_get_uint32(reverse_byte_order
, ptr
);