Commit c3cc8a99 authored by Kirill Smelkov's avatar Kirill Smelkov

bigfile/virtmem: Fix build with recent glibc

It was

	bigfile/pagefault.c:45:36: warning: ‘struct ucontext’ declared inside parameter list will not be visible outside of this definition or declaration
	 static int faulted_by(const struct ucontext *uc);
	                                    ^~~~~~~~
	bigfile/pagefault.c: In function ‘on_pagefault’:
	bigfile/pagefault.c:59:24: warning: passing argument 1 of ‘faulted_by’ from incompatible pointer type [-Wincompatible-pointer-types]
	     write = faulted_by(uc);
	                        ^~
	bigfile/pagefault.c:45:12: note: expected ‘const struct ucontext *’ but argument is of type ‘struct ucontext *’
	 static int faulted_by(const struct ucontext *uc);
	            ^~~~~~~~~~
	bigfile/pagefault.c: At top level:
	bigfile/pagefault.c:208:36: warning: ‘struct ucontext’ declared inside parameter list will not be visible outside of this definition or declaration
	 static int faulted_by(const struct ucontext *uc)
	                                    ^~~~~~~~
	bigfile/pagefault.c:208:12: error: conflicting types for ‘faulted_by’
	 static int faulted_by(const struct ucontext *uc)
	            ^~~~~~~~~~
	bigfile/pagefault.c:45:12: note: previous declaration of ‘faulted_by’ was here
	 static int faulted_by(const struct ucontext *uc);
	            ^~~~~~~~~~
	bigfile/pagefault.c: In function ‘faulted_by’:
	bigfile/pagefault.c:217:15: error: dereferencing pointer to incomplete type ‘const struct ucontext’
	     write = uc->uc_mcontext.gregs[REG_ERR] & 0x2;
	               ^~
	bigfile/pagefault.c: At top level:
	bigfile/pagefault.c:45:12: warning: ‘faulted_by’ used but never defined
	 static int faulted_by(const struct ucontext *uc);
	            ^~~~~~~~~~
	bigfile/pagefault.c:208:12: warning: ‘faulted_by’ defined but not used [-Wunused-function]
	 static int faulted_by(const struct ucontext *uc)
	            ^~~~~~~~~~

Change to using ucontext_t because apparently there is no `struct
ucontext` anymore (and man for sigaction says 3rd parameter to hander is
of type `ucontext_t *` - not `struct ucontext *` - cast to `void *`)

Explicitly include <ucontext.h> because we are dereferencing ucontext_t,
even though today it appears to be included by <signal.h>.
parent 3cfc2728
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <wendelin/bug.h> #include <wendelin/bug.h>
#include <signal.h> #include <signal.h>
#include <ucontext.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <stdint.h> #include <stdint.h>
...@@ -42,13 +43,13 @@ ...@@ -42,13 +43,13 @@
static struct sigaction prev_segv_act; static struct sigaction prev_segv_act;
static int segv_act_installed; static int segv_act_installed;
static int faulted_by(const struct ucontext *uc); static int faulted_by(const ucontext_t *uc);
/* SIGSEGV handler */ /* SIGSEGV handler */
static void on_pagefault(int sig, siginfo_t *si, void *_uc) static void on_pagefault(int sig, siginfo_t *si, void *_uc)
{ {
struct ucontext *uc = _uc; ucontext_t *uc = _uc;
unsigned write; unsigned write;
VMA *vma; VMA *vma;
...@@ -205,7 +206,7 @@ done: ...@@ -205,7 +206,7 @@ done:
* *
* @return 0 - read !0 - write * @return 0 - read !0 - write
*/ */
static int faulted_by(const struct ucontext *uc) static int faulted_by(const ucontext_t *uc)
{ {
int write; int write;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment