]>
git.proxmox.com Git - mirror_smartmontools-debian.git/blob - int64.h
4 * Home page of code is: http://smartmontools.sourceforge.net
6 * Copyright (C) 2002-8 Bruce Allen <smartmontools-support@lists.sourceforge.net>
7 * Copyright (C) 2004-8 Christian Franke
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
14 * You should have received a copy of the GNU General Public License
15 * (for example COPYING); if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #define INT64_H_CVSID "$Id: int64.h,v 1.17 2008/03/04 22:09:47 ballen4705 Exp $\n"
25 // 64 bit integer typedefs and format strings
27 #ifdef HAVE_INTTYPES_H
28 // The ISO C99 standard specifies that in C++ implementations the PRI* macros
29 // from <inttypes.h> should only be defined if explicitly requested
30 #define __STDC_FORMAT_MACROS 1
31 #include <inttypes.h> // PRId64, PRIu64, PRIx64 (also includes <stdint.h>)
34 #include <stdint.h> // int64_t, uint64_t (usually included above)
36 #ifdef HAVE_SYS_INTTYPES_H
37 #include <sys/inttypes.h>
39 #ifdef HAVE_SYS_INT_TYPES_H
40 #include <sys/int_types.h>
42 #if defined(_WIN32) && defined(_MSC_VER)
44 typedef __int64
int64_t;
45 typedef unsigned __int64
uint64_t;
47 // for systems with above includes missing (like ix86-pc-linux-gnulibc1),
48 // default to GCC if types are undefined in types.h
49 #include <sys/types.h>
51 typedef long long int64_t;
54 typedef unsigned long long uint64_t;
56 #endif // _WIN32 && _MSC_VER
57 #endif // HAVE_SYS_INT_TYPES_H
58 #endif // HAVE_SYS_INTTYPES_H
59 #endif // HAVE_STDINT_H
60 #endif // HAVE_INTTYPES_H
63 // for MSVCRT.DLL (used by both MSVC 6.0 and MinGW)
69 // If macros not defined in inttypes.h, fix here. Default is GCC
84 #if defined(_WIN32) && defined(_MSC_VER)
85 // for MSVC 6.0: "unsigned __int64 -> double" conversion not implemented (why?-)
86 __inline
double uint64_to_double(uint64_t ull
) {
87 return ((int64_t)ull
>= 0 ? (double)(int64_t)ull
:
88 ((double)(int64_t)(ull
- 9223372036854775808UI
64)) + 9223372036854775808.0);
91 #define uint64_to_double(ull) ((double)(ull))
92 #endif // _WIN32 && _MSC_VER