Percy++
A C++ implementation of Private Information Retrieval (PIR) protocols
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
percytypes.h
Go to the documentation of this file.
1 // Percy++ Copyright 2007,2012,2013,2014
2 // Ian Goldberg <iang@cs.uwaterloo.ca>,
3 // Casey Devet <cjdevet@uwaterloo.ca>,
4 // Paul Hendry <pshendry@uwaterloo.ca>,
5 // Ryan Henry <rhenry@cs.uwaterloo.ca>
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of version 2 of the GNU General Public License as
9 // published by the Free Software Foundation.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // There is a copy of the GNU General Public License in the COPYING file
17 // packaged with this plugin; if you cannot find it, write to the Free
18 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 // 02110-1301 USA
20 
21 #ifndef __PERCYTYPES_H__
22 #define __PERCYTYPES_H__
23 
24 #define __STDC_LIMIT_MACROS
25 #include <stdint.h>
26 
27 #include <stddef.h> // size_t
28 #include <sys/types.h> // off_t
29 
47 /*
48 LEGEND
49 sid_t : server ids
50 dbsize_t : blocks; words/block; bytes/word
51 dbbits_t : total bits in database
52 dboffset_t : offset into database (in bytes)
53 nqueries_t : number of simultanous queries
54 nservers_t : number of servers; privacy threshold; tau-independence
55 */
56 
57 //#if UINTPTR_MAX == 0xffffffff /* 32-bit */
58 #if defined(__i386__) /* IA-32 */
59 
60 // #warning "Detected 32-bit build."
61 
62  #define BUILD_32
63  typedef uint32_t sid_t;
64  typedef uint32_t dbsize_t;
65  typedef uint64_t dbbits_t;
66  typedef off_t dboffset_t;
67  typedef uint16_t nqueries_t;
68  typedef uint16_t nservers_t;
69 
70  #define MMAP(u,v,w,x,y,z) mmap(u,v,w,x,y,z)
71  #define PERCY_READ_LE_DBSIZE(a,b) percy_read_le_uint32(a,b)
72  #define PERCY_WRITE_LE_DBSIZE(a,b) percy_write_le_uint32(a,b)
73 
74 //#elif UINTPTR_MAX == 0xffffffffffffffff /* 64-bit */
75 #elif defined(__x86_64__)|defined(__IA64__) /* AMD64|IA-64 */
76 //#elif defined(__LP64__) /* (long int,pointer)->64-bit; int->32-bit */
77 
78 // #warning "Detected 64-bit build."
79 
80  #define BUILD_64
81  #define _W160_OPT
82 
83 #ifdef __APPLE__
84 #define off64_t off_t
85 #define mmap64 mmap
86 #endif
87 
88  typedef uint32_t sid_t;
89  typedef uint64_t dbsize_t;
90  typedef uint64_t dbbits_t;
91  typedef off64_t dboffset_t;
92  typedef uint16_t nqueries_t;
93  typedef uint16_t nservers_t;
94 
95  #define MMAP(u,v,w,x,y,z) mmap64(u,v,w,x,y,z)
96  #define PERCY_READ_LE_DBSIZE(a,b) percy_read_le_uint64(a,b)
97  #define PERCY_WRITE_LE_DBSIZE(a,b) percy_write_le_uint64(a,b)
98 
99 #else
100 
101  #error "Unsupported architecture."
102 
103 #endif
104 
105 #endif