summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2012-04-30 22:22:05 +0200
committerAndreas Baumann <abaumann@yahoo.com>2012-04-30 22:22:05 +0200
commit6297d437585be15616a47802c84f592447ed5cdd (patch)
tree19b7469df229c245b689f08ab551ae43c76c7a15 /tests
parent0803c7828d34202f14f2d4b0e9a89044ffcf0bd6 (diff)
downloadpgfuse-6297d437585be15616a47802c84f592447ed5cdd.tar.gz
pgfuse-6297d437585be15616a47802c84f592447ed5cdd.tar.bz2
changed size to a bigint
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile7
-rw-r--r--tests/testtypes.c32
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 3d09117..a092b40 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -60,6 +60,7 @@ test: testfsync testpgsql
clean:
rm -f testfsync testfsync.o
rm -f testpgsql testpgsql.o
+ rm -f testtypes testtypes.o
testfsync: testfsync.o
$(CC) -o testfsync testfsync.o
@@ -72,3 +73,9 @@ testpgsql: testpgsql.o
testpgsql.o: testpgsql.c
$(CC) -c $(CFLAGS) -o testpgsql.o testpgsql.c
+
+testtypes: testtypes.o
+ $(CC) -o testtypes testtypes.o
+
+testtypes.o: testtypes.c
+ $(CC) -c $(CFLAGS) -o testtypes.o testtypes.c
diff --git a/tests/testtypes.c b/tests/testtypes.c
new file mode 100644
index 0000000..339af5d
--- /dev/null
+++ b/tests/testtypes.c
@@ -0,0 +1,32 @@
+#define _FILE_OFFSET_BITS 64
+#include <inttypes.h>
+#include <limits.h>
+#include <stdio.h>
+#include <time.h> /* for time_t */
+#include <sys/types.h> /* for off_t */
+
+#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+#define TYPE_MAX(t) \
+ ((t) (! TYPE_SIGNED (t) \
+ ? (t) -1 \
+ : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
+
+int main(void)
+{
+ uint32_t uint32=0xffffFFFF;
+ uint64_t uint64=0xFFFFFFFFFFFFFFFF;
+ off_t offset=TYPE_MAX(off_t); /* Depends on _FILE_OFFSET_BITS */
+ size_t size=TYPE_MAX(size_t); /* Depends on int size */
+
+ printf("native int bits%20u %16x\n", sizeof(int)*CHAR_BIT, UINT_MAX);
+ printf("uint32_t max %20"PRIu32" %16"PRIx32"\n"
+ "uint64_t max %20"PRIu64" %16"PRIx64"\n"
+ "off_t max %20jd %16jx\n" /* try PRIdMAX if %jd unsupported */
+ "size_t max %20zu %16zx\n",
+ uint32, uint32,
+ uint64, uint64,
+ (intmax_t)offset, (intmax_t)offset,
+ size, size);
+
+ return 0;
+}