Fix r180999.
[gcc.git] / libgo / runtime / go-caller.c
1 /* go-caller.c -- runtime.Caller and runtime.FuncForPC for Go.
2
3 Copyright 2009 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
6
7 /* Implement runtime.Caller. */
8
9 #include <stdint.h>
10
11 #include "go-string.h"
12
13 /* The values returned by runtime.Caller. */
14
15 struct caller_ret
16 {
17 uintptr_t pc;
18 struct __go_string file;
19 int line;
20 _Bool ok;
21 };
22
23 /* Implement runtime.Caller. */
24
25 struct caller_ret Caller (int n) asm ("libgo_runtime.runtime.Caller");
26
27 struct caller_ret
28 Caller (int n __attribute__ ((unused)))
29 {
30 struct caller_ret ret;
31
32 /* A proper implementation needs to dig through the debugging
33 information. */
34 ret.pc = (uint64_t) (uintptr_t) __builtin_return_address (0);
35 ret.file.__data = NULL;
36 ret.file.__length = 0;
37 ret.line = 0;
38 ret.ok = 0;
39
40 return ret;
41 }
42
43 /* Implement runtime.FuncForPC. */
44
45 void *FuncForPC (uintptr_t) asm ("libgo_runtime.runtime.FuncForPC");
46
47 void *
48 FuncForPC(uintptr_t pc __attribute__ ((unused)))
49 {
50 return NULL;
51 }