nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* type_util.c |
2 | * Types utility routines |
||
3 | * |
||
4 | * Wireshark - Network traffic analyzer |
||
5 | * By Gerald Combs <gerald@wireshark.org> |
||
6 | * Copyright 1998 Gerald Combs |
||
7 | * |
||
8 | * This program is free software; you can redistribute it and/or |
||
9 | * modify it under the terms of the GNU General Public License |
||
10 | * as published by the Free Software Foundation; either version 2 |
||
11 | * of the License, or (at your option) any later version. |
||
12 | * |
||
13 | * This program is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | * GNU General Public License for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU General Public License |
||
19 | * along with this program; if not, write to the Free Software |
||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
21 | */ |
||
22 | |||
23 | #include "config.h" |
||
24 | |||
25 | #include "type_util.h" |
||
26 | |||
27 | /* |
||
28 | * guint64 to gdouble conversions taken from gstutils.c of GStreamer project |
||
29 | * |
||
30 | * GStreamer |
||
31 | * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> |
||
32 | * 2000 Wim Taymans <wtay@chello.be> |
||
33 | * 2002 Thomas Vander Stichele <thomas@apestaart.org> |
||
34 | * |
||
35 | * gstutils.h: Header for various utility functions |
||
36 | * |
||
37 | * GNU GPL v2 |
||
38 | * |
||
39 | */ |
||
40 | |||
41 | /* work around error C2520: conversion from unsigned __int64 to double |
||
42 | * not implemented, use signed __int64 |
||
43 | * |
||
44 | * These are implemented as functions because on some platforms a 64bit int to |
||
45 | * double conversion is not defined/implemented. |
||
46 | */ |
||
47 | |||
48 | gdouble |
||
49 | type_util_guint64_to_gdouble(guint64 value) |
||
50 | { |
||
51 | if (value & G_GUINT64_CONSTANT (0x8000000000000000)) |
||
52 | return (gdouble) ((gint64) value) + (gdouble) 18446744073709551616.; |
||
53 | else |
||
54 | return (gdouble) ((gint64) value); |
||
55 | } |
||
56 | |||
57 | guint64 |
||
58 | type_util_gdouble_to_guint64(gdouble value) |
||
59 | { |
||
60 | if (value < (gdouble) 9223372036854775808.) /* 1 << 63 */ |
||
61 | return ((guint64) ((gint64) value)); |
||
62 | |||
63 | value -= (gdouble) 18446744073709551616.; |
||
64 | return ((guint64) ((gint64) value)); |
||
65 | } |
||
66 | |||
67 | /* |
||
68 | * Editor modelines - http://www.wireshark.org/tools/modelines.html |
||
69 | * |
||
70 | * Local Variables: |
||
71 | * c-basic-offset: 2 |
||
72 | * tab-width: 8 |
||
73 | * indent-tabs-mode: nil |
||
74 | * End: |
||
75 | * |
||
76 | * ex: set shiftwidth=2 tabstop=8 expandtab: |
||
77 | * :indentSize=2:tabSize=8:noTabs=true: |
||
78 | */ |