summaryrefslogtreecommitdiff
path: root/mach-defpager
diff options
context:
space:
mode:
authorMaksym Planeta <mcsim.planeta@gmail.com>2012-01-08 14:51:42 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2012-03-26 23:43:51 +0200
commitd4b231dd9f874076c62f35590a9f6b93ca6481d7 (patch)
tree5a05a26e583aba1a191b72118be47571b9cbefbc /mach-defpager
parentf605070d37c741436b5f82745eae2a5c018e304d (diff)
Remove warnings during compilation.
* mach-defpager/kalloc.c: Added missing prototypes, headers, types. * mach-defpager/wiring.c: Likewise. * mach-defpager/default_pager.c: Likewise. * mach-defpager/main.c: Likewise. * mach-defpager/setup.c: Likewise. (S_default_pager_paging_storage): Fix wrong calling of kfree. * mach-defpager/kalloc.h: New file with prototypes from kalloc.c. * mach-defpager/default_pager.h: New file with prototypes from default_pager.c. * mach-defpager/Makefile (LCLHDRS): Add new header files.
Diffstat (limited to 'mach-defpager')
-rw-r--r--mach-defpager/Makefile2
-rw-r--r--mach-defpager/default_pager.c22
-rw-r--r--mach-defpager/default_pager.h43
-rw-r--r--mach-defpager/kalloc.c2
-rw-r--r--mach-defpager/kalloc.h30
-rw-r--r--mach-defpager/main.c2
-rw-r--r--mach-defpager/setup.c12
-rw-r--r--mach-defpager/wiring.c1
8 files changed, 100 insertions, 14 deletions
diff --git a/mach-defpager/Makefile b/mach-defpager/Makefile
index 51476552..9a4b7edf 100644
--- a/mach-defpager/Makefile
+++ b/mach-defpager/Makefile
@@ -27,7 +27,7 @@ OBJS := $(SRCS:.c=.o) \
$(addsuffix Server.o,\
memory_object default_pager memory_object_default exc) \
default_pager_replyUser.o
-LCLHDRS := file_io.h queue.h wiring.h
+LCLHDRS := file_io.h queue.h wiring.h kalloc.h default_pager.h
HURDLIBS:= threads
LDFLAGS += -static
diff --git a/mach-defpager/default_pager.c b/mach-defpager/default_pager.c
index 07274553..4b5aff89 100644
--- a/mach-defpager/default_pager.c
+++ b/mach-defpager/default_pager.c
@@ -44,9 +44,12 @@
#include <queue.h>
#include <wiring.h>
+#include <kalloc.h>
+#include <default_pager.h>
#include <assert.h>
#include <stdio.h>
+#include <string.h>
#include <file_io.h>
@@ -54,8 +57,6 @@
#define debug 0
-extern void *kalloc();
-
static char my_name[] = "(default pager):";
static struct mutex printf_lock = MUTEX_INITIALIZER;
@@ -144,9 +145,10 @@ void set_partition_of(x, p)
* Saves space, filenames can be long.
*/
unsigned int
-part_id(const unsigned char *name)
+part_id(const char *name)
{
- register unsigned int len, id, xorid;
+ register unsigned int id, xorid;
+ size_t len;
len = strlen(name);
id = xorid = 0;
@@ -157,6 +159,7 @@ part_id(const unsigned char *name)
return (id << 8) | xorid;
}
+void
partition_init()
{
mutex_init(&all_partitions.lock);
@@ -513,6 +516,7 @@ ddprintf ("choose_partition(%x,%d,%d)\n",size,cur_part,i);
vm_offset_t
pager_alloc_page(pindex, lock_it)
p_index_t pindex;
+ boolean_t lock_it;
{
register int bm_e;
register int bit;
@@ -577,6 +581,7 @@ void
pager_dealloc_page(pindex, page, lock_it)
p_index_t pindex;
register vm_offset_t page;
+ boolean_t lock_it;
{
register partition_t part;
register int bit, bm_e;
@@ -1185,7 +1190,7 @@ pager_read_offset(pager, offset)
/*
* Release a single disk block.
*/
-pager_release_offset(pager, offset)
+void pager_release_offset(pager, offset)
register dpager_t pager;
vm_offset_t offset;
{
@@ -3792,6 +3797,7 @@ dprintf("bmd %x md %x\n", bootstrap_master_device_port, mdport);
return kr;
}
+kern_return_t
default_pager_register_fileserver(pager, fileserver)
mach_port_t pager;
mach_port_t fileserver;
@@ -3808,7 +3814,7 @@ default_pager_register_fileserver(pager, fileserver)
/*
* When things do not quite workout...
*/
-no_paging_space(out_of_memory)
+void no_paging_space(out_of_memory)
boolean_t out_of_memory;
{
static char here[] = "%s *** NOT ENOUGH PAGING SPACE ***";
@@ -3818,7 +3824,7 @@ no_paging_space(out_of_memory)
panic(here, my_name);
}
-overcommitted(got_more_space, space)
+void overcommitted(got_more_space, space)
boolean_t got_more_space;
vm_size_t space; /* in pages */
{
@@ -3859,7 +3865,7 @@ overcommitted(got_more_space, space)
#endif
}
-paging_space_info(totp, freep)
+void paging_space_info(totp, freep)
vm_size_t *totp, *freep;
{
register vm_size_t total, free;
diff --git a/mach-defpager/default_pager.h b/mach-defpager/default_pager.h
new file mode 100644
index 00000000..f4cdda64
--- /dev/null
+++ b/mach-defpager/default_pager.h
@@ -0,0 +1,43 @@
+/* Backing store access callbacks for Hurd version of Mach default pager.
+ Copyright (C) 2012 Free Software Foundation, Inc.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/* Prototypes for working with paging partitions and files */
+
+#ifndef _DEFAULT_PAGER_H_
+#define _DEFAULT_PAGER_H_
+
+#include <file_io.h>
+
+void partition_init();
+
+void create_paging_partition(const char *name, struct file_direct *fdp,
+ int isa_file, int linux_signature);
+kern_return_t destroy_paging_partition(char *name, void **pp_private);
+
+kern_return_t add_paging_file(mach_port_t master_device_port,
+ char *file_name, int linux_signature);
+kern_return_t remove_paging_file (char *file_name);
+
+void paging_space_info(vm_size_t *totp, vm_size_t *freep);
+void no_paging_space(boolean_t out_of_memory);
+void overcommitted(boolean_t got_more_space, vm_size_t space);
+
+void panic (const char *fmt, ...);
+
+#endif /* _DEFAULT_PAGER_H_ */
diff --git a/mach-defpager/kalloc.c b/mach-defpager/kalloc.c
index 5d91aceb..d9b18c02 100644
--- a/mach-defpager/kalloc.c
+++ b/mach-defpager/kalloc.c
@@ -36,6 +36,8 @@
#include <cthreads.h> /* for spin locks */
#include <malloc.h> /* for malloc_hook/free_hook */
+#include "wiring.h"
+
static void init_hook (void);
static void *malloc_hook (size_t size, const void *caller);
static void free_hook (void *ptr, const void *caller);
diff --git a/mach-defpager/kalloc.h b/mach-defpager/kalloc.h
new file mode 100644
index 00000000..8f52f1a5
--- /dev/null
+++ b/mach-defpager/kalloc.h
@@ -0,0 +1,30 @@
+/* Backing store access callbacks for Hurd version of Mach default pager.
+ Copyright (C) 2012 Free Software Foundation, Inc.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/*
+ * General kernel memory allocator.
+ */
+
+#ifndef _KALLOC_H_
+#define _KALLOC_H_
+
+void *kalloc (vm_size_t size);
+void kfree (void *data, vm_size_t size);
+
+#endif /* _KALLOC_H_ */
diff --git a/mach-defpager/main.c b/mach-defpager/main.c
index 0be9dee1..c44c86cb 100644
--- a/mach-defpager/main.c
+++ b/mach-defpager/main.c
@@ -31,6 +31,7 @@
#include <stdarg.h>
#include <error.h>
#include <signal.h>
+#include <string.h>
/* XXX */
#include <fcntl.h>
@@ -42,6 +43,7 @@
#include <hurd/fd.h>
/* XXX */
+#include <default_pager.h>
extern
vm_size_t cthread_wait_stack_size;
diff --git a/mach-defpager/setup.c b/mach-defpager/setup.c
index 05c19f33..080b0fa6 100644
--- a/mach-defpager/setup.c
+++ b/mach-defpager/setup.c
@@ -22,6 +22,11 @@
#include <stddef.h>
#include <assert.h>
#include <mach.h>
+#include <string.h>
+#include <strings.h>
+
+#include <default_pager.h>
+#include <kalloc.h>
#include "file_io.h"
#include "default_pager_S.h"
@@ -32,9 +37,6 @@ int page_aligned (vm_offset_t num)
return trunc_page (num) == num;
}
-/* From serverboot/kalloc.c. */
-extern void *kalloc (vm_size_t);
-
extern mach_port_t default_pager_default_port; /* default_pager.c */
kern_return_t
@@ -87,7 +89,7 @@ S_default_pager_paging_storage (mach_port_t pager,
fdp->runs[i].length = runs[i + 1];
if (fdp->runs[i].start + fdp->runs[i].length > devsize)
{
- kfree (fdp);
+ kfree (fdp, offsetof (struct file_direct, runs[nrun]));
return EINVAL;
}
fdp->fd_size += fdp->runs[i].length;
@@ -295,7 +297,7 @@ remove_paging_file (char *file_name)
struct file_direct *fdp = 0;
kern_return_t kr;
- kr = destroy_paging_partition(file_name, &fdp);
+ kr = destroy_paging_partition(file_name, (void **)&fdp);
if (kr == KERN_SUCCESS && fdp != 0)
{
mach_port_deallocate (mach_task_self (), fdp->device);
diff --git a/mach-defpager/wiring.c b/mach-defpager/wiring.c
index 585a3075..8bf49934 100644
--- a/mach-defpager/wiring.c
+++ b/mach-defpager/wiring.c
@@ -29,6 +29,7 @@
#include <mach.h>
#include <mach_init.h>
#include <mach/machine/vm_param.h>
+#include "default_pager.h"
mach_port_t this_task; /* our task */
mach_port_t priv_host_port = MACH_PORT_NULL;