Skip to content

Commit 0071b1c

Browse files
author
arno
committed
- Ensure SIZE_MAX is defined in C++ and hence PRISIZET is set correctly and hence fscanf for .mbinmap reads a sane value. git-svn-id: http://svn.tribler.org/libswift/branches/ppsp-03@32466 001aeff7-3401-0410-a489-f7902fc005dd
1 parent ae8de0b commit 0071b1c

8 files changed

+18
-11
lines changed

binmap.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Arno, 2013-06-11: Must come first to ensure SIZE_MAX etc are defined
2+
#include "compat.h"
13
#include <cassert>
24
#include <cstddef>
35
#include <cstdlib>

cmdgw.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
* Copyright 2010-2012 TECHNISCHE UNIVERSITEIT DELFT. All rights reserved.
77
*
88
*/
9-
#include <iostream>
10-
#include <sstream>
11-
129
#include "swift.h"
1310
#include <event2/buffer.h>
1411
#include <event2/bufferevent.h>
1512
#include <event2/listener.h>
1613

14+
#include <iostream>
15+
#include <sstream>
1716

1817
using namespace swift;
1918

compat.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ typedef int int32_t;
1919
typedef __int64 int64_t;
2020
typedef unsigned __int64 uint64_t;
2121
#else
22+
// Arno, 2013-06-11: Must be defined to get SIZE_MAX in C++
23+
#define __STDC_LIMIT_MACROS
2224
#include <stdint.h>
2325
#endif
2426

@@ -42,6 +44,7 @@ typedef unsigned __int64 uint64_t;
4244
#include <sys/stat.h>
4345
#endif
4446

47+
#include <limits.h>
4548
#include <fcntl.h>
4649
#include <cstdio>
4750
#include <cstdlib>
@@ -92,7 +95,6 @@ typedef void* setsockoptptr_t;
9295
#endif
9396

9497
#ifndef LONG_MAX
95-
#include <limits>
9698
#define LONG_MAX numeric_limits<int>::max()
9799
#endif
98100

@@ -103,6 +105,10 @@ typedef void* setsockoptptr_t;
103105

104106

105107
// Arno, 2012-01-05: Handle 64-bit size_t & printf+scanf
108+
#ifndef SIZE_MAX
109+
#error SIZE_MAX undefined, check stdint.h and __STDC_LIMIT_MACROS
110+
#endif
111+
106112
#if SIZE_MAX > UINT_MAX
107113
#define PRISIZET "%llu"
108114
#else

hashtree.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright 2009-2016 TECHNISCHE UNIVERSITEIT DELFT. All rights reserved.
77
*
88
*/
9-
9+
#include "compat.h"
1010
#include "hashtree.h"
1111
#include "bin_utils.h"
1212
//#include <openssl/sha.h>
@@ -15,7 +15,6 @@
1515
#include <cstring>
1616
#include <cstdlib>
1717
#include <fcntl.h>
18-
#include "compat.h"
1918
#include "swift.h"
2019

2120
#include <iostream>

sendrecv.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
* Copyright 2009-2016 TECHNISCHE UNIVERSITEIT DELFT. All rights reserved.
77
*
88
*/
9+
// Arno, 2013-06-11: Must come first to ensure SIZE_MAX etc are defined
10+
#include "compat.h"
911
#include "bin_utils.h"
1012
#include "swift.h"
1113
#include <algorithm> // kill it
1214
#include <cassert>
1315
#include <cfloat>
1416
#include <sstream>
15-
#include "compat.h"
1617

1718
using namespace swift;
1819
using namespace std;

swift.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
#ifndef SWIFT_H
6565
#define SWIFT_H
6666

67+
// Arno, 2013-06-11: Must come first to ensure SIZE_MAX etc are defined
68+
#include "compat.h"
6769
#include <deque>
6870
#include <vector>
6971
#include <set>
@@ -72,7 +74,6 @@
7274
#include <algorithm>
7375
#include <string>
7476

75-
#include "compat.h"
7677
#include <event2/event.h>
7778
#include <event2/event_struct.h>
7879
#include <event2/buffer.h>

transfer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
* Copyright 2009-2016 TECHNISCHE UNIVERSITEIT DELFT. All rights reserved.
77
*
88
*/
9+
#include "swift.h"
910
#include <errno.h>
1011
#include <string>
1112
#include <sstream>
12-
#include "swift.h"
1313

1414
#include "ext/seq_picker.cpp" // FIXME FIXME FIXME FIXME
1515
#include "ext/vod_picker.cpp"

zerohashtree.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright 2009-2016 TECHNISCHE UNIVERSITEIT DELFT. All rights reserved.
88
*
99
*/
10-
10+
#include "compat.h"
1111
#include "hashtree.h"
1212
#include "bin_utils.h"
1313
//#include <openssl/sha.h>
@@ -16,7 +16,6 @@
1616
#include <cstring>
1717
#include <cstdlib>
1818
#include <fcntl.h>
19-
#include "compat.h"
2019
#include "swift.h"
2120

2221
#include <iostream>

0 commit comments

Comments
 (0)