authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-21 10:39:13-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-21 10:39:13-04:00
loge3c524c1d482a845bb2d6555bda386739c862226
treef787e6def3e09691db95852e1a264eb660585af1
parentecb71d1dd34e98fc9813cffa473f83127e6e3d01

rename `@ptrcast` to `@ptrCast` to follow convention


17 files changed, 37 insertions(+), 37 deletions(-)

doc/langref.md+1-1
......@@ -623,7 +623,7 @@ calls the public `panic` function exposed in the root source file, or
623623if there is not one specified, invokes the one provided in
624624`std/special/panic.zig`.
625625
626### @ptrcast(comptime DestType: type, value: var) -> DestType
626### @ptrCast(comptime DestType: type, value: var) -> DestType
627627
628628Converts a pointer of one type to a pointer of another type.
629629
src/codegen.cpp+1-1
......@@ -4551,7 +4551,7 @@ static void define_builtin_fns(CodeGen *g) {
45514551 create_builtin_fn(g, BuiltinFnIdSetGlobalSection, "setGlobalSection", 2);
45524552 create_builtin_fn(g, BuiltinFnIdSetGlobalLinkage, "setGlobalLinkage", 2);
45534553 create_builtin_fn(g, BuiltinFnIdPanic, "panic", 1);
4554 create_builtin_fn(g, BuiltinFnIdPtrCast, "ptrcast", 2);
4554 create_builtin_fn(g, BuiltinFnIdPtrCast, "ptrCast", 2);
45554555 create_builtin_fn(g, BuiltinFnIdIntToPtr, "intToPtr", 2);
45564556 create_builtin_fn(g, BuiltinFnIdEnumTagName, "enumTagName", 1);
45574557 create_builtin_fn(g, BuiltinFnIdFieldParentPtr, "fieldParentPtr", 3);
std/buf_map.zig+1-1
......@@ -58,7 +58,7 @@ pub const BufMap = struct {
5858
5959 fn free(self: &BufMap, value: []const u8) {
6060 // remove the const
61 const mut_value = @ptrcast(&u8, value.ptr)[0...value.len];
61 const mut_value = @ptrCast(&u8, value.ptr)[0...value.len];
6262 self.hash_map.allocator.free(mut_value);
6363 }
6464
std/buf_set.zig+1-1
......@@ -47,7 +47,7 @@ pub const BufSet = struct {
4747
4848 fn free(self: &BufSet, value: []const u8) {
4949 // remove the const
50 const mut_value = @ptrcast(&u8, value.ptr)[0...value.len];
50 const mut_value = @ptrCast(&u8, value.ptr)[0...value.len];
5151 self.hash_map.allocator.free(mut_value);
5252 }
5353
std/debug.zig+1-1
......@@ -74,7 +74,7 @@ pub fn writeStackTrace(out_stream: &io.OutStream) -> %void {
7474 const name = %return compile_unit.die.getAttrString(st, DW.AT_name);
7575
7676 %return out_stream.printf("{} -> {}\n", return_address, name);
77 maybe_fp = *@ptrcast(&const ?&const u8, fp);
77 maybe_fp = *@ptrCast(&const ?&const u8, fp);
7878 }
7979 },
8080 ObjectFormat.coff => {
std/hash_map.zig+1-1
......@@ -250,7 +250,7 @@ test "basicHashMapTest" {
250250}
251251
252252fn hash_i32(x: i32) -> u32 {
253 *@ptrcast(&u32, &x)
253 *@ptrCast(&u32, &x)
254254}
255255
256256fn eql_i32(a: i32, b: i32) -> bool {
std/os/darwin.zig+1-1
......@@ -59,7 +59,7 @@ pub fn exit(status: usize) -> noreturn {
5959
6060/// Get the errno from a syscall return value, or 0 for no error.
6161pub fn getErrno(r: usize) -> usize {
62 const signed_r = *@ptrcast(&const isize, &r);
62 const signed_r = *@ptrCast(&const isize, &r);
6363 if (signed_r > -4096 and signed_r < 0) usize(-signed_r) else 0
6464}
6565
std/os/index.zig+1-1
......@@ -752,7 +752,7 @@ pub const Dir = struct {
752752 break;
753753 }
754754 }
755 const linux_entry = @ptrcast(&LinuxEntry, &self.buf[self.index]);
755 const linux_entry = @ptrCast(&LinuxEntry, &self.buf[self.index]);
756756 const next_index = self.index + linux_entry.d_reclen;
757757 self.index = next_index;
758758
std/os/linux.zig+3-3
......@@ -251,8 +251,8 @@ pub const DT_LNK = 10;
251251pub const DT_SOCK = 12;
252252pub const DT_WHT = 14;
253253
254fn unsigned(s: i32) -> u32 { *@ptrcast(&u32, &s) }
255fn signed(s: u32) -> i32 { *@ptrcast(&i32, &s) }
254fn unsigned(s: i32) -> u32 { *@ptrCast(&u32, &s) }
255fn signed(s: u32) -> i32 { *@ptrCast(&i32, &s) }
256256pub fn WEXITSTATUS(s: i32) -> i32 { signed((unsigned(s) & 0xff00) >> 8) }
257257pub fn WTERMSIG(s: i32) -> i32 { signed(unsigned(s) & 0x7f) }
258258pub fn WSTOPSIG(s: i32) -> i32 { WEXITSTATUS(s) }
......@@ -262,7 +262,7 @@ pub fn WIFSIGNALED(s: i32) -> bool { (unsigned(s)&0xffff)-%1 < 0xff }
262262
263263/// Get the errno from a syscall return value, or 0 for no error.
264264pub fn getErrno(r: usize) -> usize {
265 const signed_r = *@ptrcast(&const isize, &r);
265 const signed_r = *@ptrCast(&const isize, &r);
266266 if (signed_r > -4096 and signed_r < 0) usize(-signed_r) else 0
267267}
268268
std/special/bootstrap.zig+3-3
......@@ -31,8 +31,8 @@ export nakedcc fn _start() -> noreturn {
3131
3232fn callMainAndExit() -> noreturn {
3333 const argc = *argc_ptr;
34 const argv = @ptrcast(&&u8, &argc_ptr[1]);
35 const envp = @ptrcast(&?&u8, &argv[argc + 1]);
34 const argv = @ptrCast(&&u8, &argc_ptr[1]);
35 const envp = @ptrCast(&?&u8, &argv[argc + 1]);
3636 callMain(argc, argv, envp) %% exit(1);
3737 exit(0);
3838}
......@@ -42,7 +42,7 @@ fn callMain(argc: usize, argv: &&u8, envp: &?&u8) -> %void {
4242
4343 var env_count: usize = 0;
4444 while (envp[env_count] != null; env_count += 1) {}
45 std.os.environ_raw = @ptrcast(&&u8, envp)[0...env_count];
45 std.os.environ_raw = @ptrCast(&&u8, envp)[0...env_count];
4646
4747 return root.main();
4848}
std/special/compiler_rt.zig+12-12
......@@ -15,7 +15,7 @@ export fn __udivdi3(a: du_int, b: du_int) -> du_int {
1515
1616fn du_int_to_udwords(x: du_int) -> udwords {
1717 @setDebugSafety(this, false);
18 return *@ptrcast(&udwords, &x);
18 return *@ptrCast(&udwords, &x);
1919}
2020
2121export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
......@@ -66,7 +66,7 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
6666 if (var rem ?= maybe_rem) {
6767 r[high] = n[high] % d[high];
6868 r[low] = 0;
69 *rem = *@ptrcast(&du_int, &r[0]);
69 *rem = *@ptrCast(&du_int, &r[0]);
7070 }
7171 return n[high] / d[high];
7272 }
......@@ -78,7 +78,7 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
7878 if (var rem ?= maybe_rem) {
7979 r[low] = n[low];
8080 r[high] = n[high] & (d[high] - 1);
81 *rem = *@ptrcast(&du_int, &r[0]);
81 *rem = *@ptrCast(&du_int, &r[0]);
8282 }
8383 return n[high] >> @ctz(d[high]);
8484 }
......@@ -89,7 +89,7 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
8989 // 0 <= sr <= n_uword_bits - 2 or sr large
9090 if (sr > n_uword_bits - 2) {
9191 if (var rem ?= maybe_rem) {
92 *rem = *@ptrcast(&du_int, &n[0]);
92 *rem = *@ptrCast(&du_int, &n[0]);
9393 }
9494 return 0;
9595 }
......@@ -113,12 +113,12 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
113113 *rem = n[low] & (d[low] - 1);
114114 }
115115 if (d[low] == 1) {
116 return *@ptrcast(&du_int, &n[0]);
116 return *@ptrCast(&du_int, &n[0]);
117117 }
118118 sr = @ctz(d[low]);
119119 q[high] = n[high] >> sr;
120120 q[low] = (n[high] << (n_uword_bits - sr)) | (n[low] >> sr);
121 return *@ptrcast(&du_int, &q[0]);
121 return *@ptrCast(&du_int, &q[0]);
122122 }
123123 // K X
124124 // ---
......@@ -154,7 +154,7 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
154154 // 0 <= sr <= n_uword_bits - 1 or sr large
155155 if (sr > n_uword_bits - 1) {
156156 if (var rem ?= maybe_rem) {
157 *rem = *@ptrcast(&du_int, &n[0]);
157 *rem = *@ptrCast(&du_int, &n[0]);
158158 }
159159 return 0;
160160 }
......@@ -191,17 +191,17 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
191191 // r.all -= d.all;
192192 // carry = 1;
193193 // }
194 const s: di_int = (di_int)(*@ptrcast(&du_int, &d[0]) - *@ptrcast(&du_int, &r[0]) - 1) >> (n_udword_bits - 1);
194 const s: di_int = (di_int)(*@ptrCast(&du_int, &d[0]) - *@ptrCast(&du_int, &r[0]) - 1) >> (n_udword_bits - 1);
195195 carry = su_int(s & 1);
196 *@ptrcast(&du_int, &r[0]) -= *@ptrcast(&du_int, &d[0]) & u64(s);
196 *@ptrCast(&du_int, &r[0]) -= *@ptrCast(&du_int, &d[0]) & u64(s);
197197
198198 sr -= 1;
199199 }
200 *@ptrcast(&du_int, &q[0]) = (*@ptrcast(&du_int, &q[0]) << 1) | u64(carry);
200 *@ptrCast(&du_int, &q[0]) = (*@ptrCast(&du_int, &q[0]) << 1) | u64(carry);
201201 if (var rem ?= maybe_rem) {
202 *rem = *@ptrcast(&du_int, &r[0]);
202 *rem = *@ptrCast(&du_int, &r[0]);
203203 }
204 return *@ptrcast(&du_int, &q[0]);
204 return *@ptrCast(&du_int, &q[0]);
205205}
206206
207207export fn __umoddi3(a: du_int, b: du_int) -> du_int {
test/cases/cast.zig+1-1
......@@ -16,7 +16,7 @@ test "numLitIntToPtrCast" {
1616test "pointerReinterpretConstFloatToInt" {
1717 const float: f64 = 5.99999999999994648725e-01;
1818 const float_ptr = &float;
19 const int_ptr = @ptrcast(&i32, float_ptr);
19 const int_ptr = @ptrCast(&i32, float_ptr);
2020 const int_val = *int_ptr;
2121 assert(int_val == 858993411);
2222}
test/cases/generics.zig+1-1
......@@ -121,5 +121,5 @@ test "genericFnWithImplicitCast" {
121121}
122122fn getByte(ptr: ?&const u8) -> u8 {*??ptr}
123123fn getFirstByte(comptime T: type, mem: []const T) -> u8 {
124 getByte(@ptrcast(&const u8, &mem[0]))
124 getByte(@ptrCast(&const u8, &mem[0]))
125125}
test/cases/misc.zig+4-4
......@@ -246,15 +246,15 @@ test "typeEquality" {
246246
247247const global_a: i32 = 1234;
248248const global_b: &const i32 = &global_a;
249const global_c: &const f32 = @ptrcast(&const f32, global_b);
249const global_c: &const f32 = @ptrCast(&const f32, global_b);
250250test "compileTimeGlobalReinterpret" {
251 const d = @ptrcast(&const i32, global_c);
251 const d = @ptrCast(&const i32, global_c);
252252 assert(*d == 1234);
253253}
254254
255255test "explicitCastMaybePointers" {
256256 const a: ?&i32 = undefined;
257 const b: ?&f32 = @ptrcast(?&f32, a);
257 const b: ?&f32 = @ptrCast(?&f32, a);
258258}
259259
260260test "genericMallocFree" {
......@@ -263,7 +263,7 @@ test "genericMallocFree" {
263263}
264264const some_mem : [100]u8 = undefined;
265265fn memAlloc(comptime T: type, n: usize) -> %[]T {
266 return @ptrcast(&T, &some_mem[0])[0...n];
266 return @ptrCast(&T, &some_mem[0])[0...n];
267267}
268268fn memFree(comptime T: type, memory: []T) { }
269269
test/cases/struct.zig+1-1
......@@ -41,7 +41,7 @@ const VoidStructFieldsFoo = struct {
4141
4242test "fn" {
4343 var foo: StructFoo = undefined;
44 @memset(@ptrcast(&u8, &foo), 0, @sizeOf(StructFoo));
44 @memset(@ptrCast(&u8, &foo), 0, @sizeOf(StructFoo));
4545 foo.a += 1;
4646 foo.b = foo.a == 1;
4747 testFoo(foo);
test/compare_output.zig+3-3
......@@ -262,8 +262,8 @@ pub fn addCases(cases: &tests.CompareOutputContext) {
262262 \\const c = @cImport(@cInclude("stdlib.h"));
263263 \\
264264 \\export fn compare_fn(a: ?&const c_void, b: ?&const c_void) -> c_int {
265 \\ const a_int = @ptrcast(&i32, a ?? unreachable);
266 \\ const b_int = @ptrcast(&i32, b ?? unreachable);
265 \\ const a_int = @ptrCast(&i32, a ?? unreachable);
266 \\ const b_int = @ptrCast(&i32, b ?? unreachable);
267267 \\ if (*a_int < *b_int) {
268268 \\ -1
269269 \\ } else if (*a_int > *b_int) {
......@@ -276,7 +276,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) {
276276 \\export fn main() -> c_int {
277277 \\ var array = []u32 { 1, 7, 3, 2, 0, 9, 4, 8, 6, 5 };
278278 \\
279 \\ c.qsort(@ptrcast(&c_void, &array[0]), c_ulong(array.len), @sizeOf(i32), compare_fn);
279 \\ c.qsort(@ptrCast(&c_void, &array[0]), c_ulong(array.len), @sizeOf(i32), compare_fn);
280280 \\
281281 \\ for (array) |item, i| {
282282 \\ if (item != i) {
test/compile_errors.zig+1-1
......@@ -1475,7 +1475,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
14751475
14761476 cases.add("ptrcast to non-pointer",
14771477 \\export fn entry(a: &i32) -> usize {
1478 \\ return @ptrcast(usize, a);
1478 \\ return @ptrCast(usize, a);
14791479 \\}
14801480 , ".tmp_source.zig:2:21: error: expected pointer, found 'usize'");
14811481