ref: 3e38194d72b2b017b85bf85f11ef4e580d44be4f
parent: 59245c73f0645e4e2ca1b01b3e3551dbbc5273d9
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Jan 6 23:39:09 EST 2016
introduce signed intptr and %z format modifier for formating uintptr and intptr
--- a/386/include/u.h
+++ b/386/include/u.h
@@ -6,6 +6,7 @@
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
+typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;
--- a/68000/include/u.h
+++ b/68000/include/u.h
@@ -6,6 +6,7 @@
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
+typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;
--- a/68020/include/u.h
+++ b/68020/include/u.h
@@ -6,6 +6,7 @@
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
+typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;
--- a/alpha/include/u.h
+++ b/alpha/include/u.h
@@ -6,6 +6,7 @@
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
+typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;
--- a/amd64/include/u.h
+++ b/amd64/include/u.h
@@ -6,6 +6,7 @@
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
+typedef long long intptr;
typedef unsigned long long uintptr;
typedef unsigned long usize;
typedef uint Rune;
--- a/arm/include/u.h
+++ b/arm/include/u.h
@@ -7,6 +7,7 @@
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
+typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;
--- a/mips/include/u.h
+++ b/mips/include/u.h
@@ -6,6 +6,7 @@
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
+typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;
--- a/power/include/u.h
+++ b/power/include/u.h
@@ -6,6 +6,7 @@
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
+typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;
--- a/power64/include/u.h
+++ b/power64/include/u.h
@@ -6,6 +6,7 @@
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
+typedef long long intptr;
typedef unsigned long long uintptr;
typedef unsigned long usize;
typedef uint Rune;
--- a/sparc/include/u.h
+++ b/sparc/include/u.h
@@ -6,6 +6,7 @@
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
+typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;
--- a/sparc64/include/u.h
+++ b/sparc64/include/u.h
@@ -6,6 +6,7 @@
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
+typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;
--- a/spim/include/u.h
+++ b/spim/include/u.h
@@ -6,6 +6,7 @@
typedef signed char schar;
typedef long long vlong;
typedef unsigned long long uvlong;
+typedef long intptr;
typedef unsigned long uintptr;
typedef unsigned long usize;
typedef uint Rune;
--- a/sys/include/libc.h
+++ b/sys/include/libc.h
@@ -194,6 +194,14 @@
#pragma varargck type "lo" ulong
#pragma varargck type "lx" ulong
#pragma varargck type "lb" ulong
+#pragma varargck type "zd" intptr
+#pragma varargck type "zo" intptr
+#pragma varargck type "zx" intptr
+#pragma varargck type "zb" intptr
+#pragma varargck type "zd" uintptr
+#pragma varargck type "zo" uintptr
+#pragma varargck type "zx" uintptr
+#pragma varargck type "zb" uintptr
#pragma varargck type "d" int
#pragma varargck type "o" int
#pragma varargck type "x" int
--- a/sys/src/9/port/lib.h
+++ b/sys/src/9/port/lib.h
@@ -98,6 +98,14 @@
#pragma varargck type "lb" ulong
#pragma varargck type "ld" ulong
#pragma varargck type "lx" ulong
+#pragma varargck type "zd" intptr
+#pragma varargck type "zo" intptr
+#pragma varargck type "zx" intptr
+#pragma varargck type "zb" intptr
+#pragma varargck type "zd" uintptr
+#pragma varargck type "zo" uintptr
+#pragma varargck type "zx" uintptr
+#pragma varargck type "zb" uintptr
#pragma varargck type "b" int
#pragma varargck type "d" int
#pragma varargck type "x" int
--- a/sys/src/cmd/cc/dpchk.c
+++ b/sys/src/cmd/cc/dpchk.c
@@ -165,6 +165,7 @@
argflag('*', Fstar);
argflag('l', Fl);
+ argflag('z', ewidth[TVLONG]==ewidth[TIND] ? Fvl : Fl);
argflag('o', Fverb);
flagbits['x'] = flagbits['o'];
--- a/sys/src/libc/fmt/dofmt.c
+++ b/sys/src/libc/fmt/dofmt.c
@@ -504,6 +504,11 @@
f->flags |= FmtVLong;
f->flags |= FmtLong;
break;
+ case 'z':
+ f->flags |= FmtLong;
+ if(sizeof(uintptr) == sizeof(uvlong))
+ f->flags |= FmtVLong;
+ break;
}
return 1;
}
--- a/sys/src/libc/fmt/fmt.c
+++ b/sys/src/libc/fmt/fmt.c
@@ -48,6 +48,7 @@
's', _strfmt,
'u', _flagfmt,
'x', _ifmt,
+ 'z', _flagfmt,
0, nil,
};