4 #include <sys/newsig.h>
8 #define MAP_ANON MAP_ANONYMOUS
10 #include "diskBack.unix.c"
11 #include "mmap-protect.c"
13 #include "recv.nonblock.c"
14 #include "setenv.putenv.c"
22 static struct pstnames pst_type_names
[] =
23 {{ PS_NOTUSED
, "unused" },
24 { PS_USER_AREA
, "user" },
27 { PS_STACK
, "stack" },
28 { PS_SHARED
, "shared" },
29 { PS_NULLDEREF
, "null" },
32 { PS_GRAPHICS
, "gfx" },
33 { PS_GRAPHICS_DMA
, "gfxdma" },
35 { PS_RSESTACK
, "rsestack" },
40 pst_type_name(int type
)
44 for (i
= 0; pst_type_names
[i
].name
; i
++)
45 if (pst_type_names
[i
].type
== type
)
46 return pst_type_names
[i
].name
;
51 pst_filename(struct pst_vm_status vm
)
53 static char fname
[256];
54 #ifdef PSTAT_FILEDETAILS
55 if (pstat_getpathname (fname
, sizeof (fname
), &vm
.pst_fid
) < 0)
57 strcpy (fname
, "unknown");
61 void GC_displayMem (void) {
63 struct pst_vm_status buf
;
64 size_t page_size
= sysconf (_SC_PAGE_SIZE
);
66 printf("va_start va_end perms type phys filename\n");
67 printf("--------+--------+-----+-------+------+-----------\n");
69 if (pstat_getprocvm (&buf
, sizeof (buf
), 0, i
) < 0)
71 printf("%p %p %s%s%s %-8s %4d %s\n",
73 (void*)(buf
.pst_vaddr
+ buf
.pst_length
* page_size
- 1),
74 (buf
.pst_flags
& PS_PROT_READ
) ? "-" : "r",
75 (buf
.pst_flags
& PS_PROT_WRITE
) ? "-" : "w",
76 (buf
.pst_flags
& PS_PROT_EXECUTE
) ? "-" : "x",
77 pst_type_name (buf
.pst_type
),
84 static void catcher (__attribute__ ((unused
)) int signo
,
85 __attribute__ ((unused
)) siginfo_t
* info
,
87 ucontext_t
* ucp
= (ucontext_t
*)context
;
88 GC_handleSigProf ((code_pointer
) (ucp
->uc_link
));
91 void GC_setSigProfHandler (struct sigaction
*sa
) {
92 sa
->sa_flags
= SA_ONSTACK
| SA_RESTART
| SA_SIGINFO
;
93 sa
->sa_sigaction
= (void (*)(int, siginfo_t
*, void*))catcher
;
96 size_t GC_pageSize (void) {
97 struct pst_static buf
;
99 if (pstat_getstatic (&buf
, sizeof (buf
), 1, 0) < 0)
100 diee ("failed to get page size");
101 return buf
.page_size
;
104 uintmax_t GC_physMem (void) {
105 struct pst_static buf
;
108 if (pstat_getstatic (&buf
, sizeof (buf
), 1, 0) < 0)
109 diee ("failed to get physical memory size");
110 physMem
= (uintmax_t)buf
.physical_memory
* (uintmax_t)buf
.page_size
;
115 float modff (float x
, float *iptr
)
118 d
= modf ((double)x
, &i
);
123 float rintf (float x
) {
124 return (float)rint ((double)x
);
127 float frexpf (float x
, int *e
) {
128 return (float)frexp ((double)x
, e
);
131 float ldexpf (float x
, int e
) {
132 return (float)ldexp ((double)x
, e
);
134 #endif /* __hppa__ */