ref: 4308f6e7e6586e3a27aa46c4d54c434b8533b16d
parent: 772afbe98c7e74be35e7e5318967ce594e4d93e8
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Jan 7 14:04:12 EST 2016
ape/fmt: %p and %z format for amd64
--- a/sys/src/ape/lib/fmt/dofmt.c
+++ b/sys/src/ape/lib/fmt/dofmt.c
@@ -348,7 +348,11 @@
break;
}
if(f->r == 'p'){
- u = (ulong)va_arg(f->args, void*);
+ if(sizeof(void*) == sizeof(uvlong)){
+ isv = 1;
+ vu = (uvlong)va_arg(f->args, void*);
+ } else
+ u = (ulong)va_arg(f->args, void*);
f->r = 'x';
fl |= FmtUnsigned;
}else if(fl & FmtVLong){
@@ -537,6 +541,11 @@
if(f->flags & FmtLong)
f->flags |= FmtVLong;
f->flags |= FmtLong;
+ break;
+ case 'z':
+ f->flags |= FmtLong;
+ if(sizeof(void*) == sizeof(vlong))
+ f->flags |= FmtVLong;
break;
}
return 1;
--- a/sys/src/ape/lib/fmt/fmt.c
+++ b/sys/src/ape/lib/fmt/fmt.c
@@ -66,6 +66,7 @@
's', __strfmt,
'u', __flagfmt, /* in Unix, __ifmt */
'x', __ifmt,
+ 'z', __flagfmt,
0, nil,
};
--- a/sys/src/ape/lib/fmt/mkfile
+++ b/sys/src/ape/lib/fmt/mkfile
@@ -53,7 +53,7 @@
strtod.$O: nan.h
test: $LIB test.$O
- $CC -o test test.$O $LIB -L$PLAN9/lib -lutf
+ $CC -o test test.$O $LIB -lutf
CFLAGS=-c -D_POSIX_SOURCE -D_PLAN9_SOURCE -D_BSD_EXTENSION
--- a/sys/src/ape/lib/fmt/test.c
+++ b/sys/src/ape/lib/fmt/test.c
@@ -35,5 +35,7 @@
print("%f\n", 3.1415927/4);
print("%d\n", 23);
print("%i\n", 23);
+ print("%p\n", argv);
+ print("%zd\n", &argv[1] - &argv[0]);
return 0;
}