From 14d765b9a06a99ab0a8d95f3a5cd0337fcd8e7b5 Mon Sep 17 00:00:00 2001 From: christos Date: Thu, 16 Oct 1997 23:21:47 +0000 Subject: [PATCH] caddr_t -> void * PR/4269: Chris Demetriou: Add MS_* to msync() --- lib/libc/sys/minherit.2 | 4 +-- lib/libc/sys/mlock.2 | 6 ++-- lib/libc/sys/mmap.2 | 6 ++-- lib/libc/sys/mmap.c | 8 ++--- lib/libc/sys/mprotect.2 | 4 +-- lib/libc/sys/msync.2 | 76 ++++++++++++++++++++++++++++------------- lib/libc/sys/munmap.2 | 4 +-- 7 files changed, 68 insertions(+), 40 deletions(-) diff --git a/lib/libc/sys/minherit.2 b/lib/libc/sys/minherit.2 index 45e99206248f..18c280b8a076 100644 --- a/lib/libc/sys/minherit.2 +++ b/lib/libc/sys/minherit.2 @@ -1,4 +1,4 @@ -.\" $NetBSD: minherit.2,v 1.1 1997/09/08 18:42:44 chuck Exp $ +.\" $NetBSD: minherit.2,v 1.2 1997/10/16 23:21:47 christos Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -43,7 +43,7 @@ .Fd #include .Fd #include .Ft int -.Fn minherit "caddr_t addr" "size_t len" "int inherit" +.Fn minherit "void *addr" "size_t len" "int inherit" .Sh DESCRIPTION The .Fn minherit diff --git a/lib/libc/sys/mlock.2 b/lib/libc/sys/mlock.2 index 135232bb1fc2..5acf1f0589fe 100644 --- a/lib/libc/sys/mlock.2 +++ b/lib/libc/sys/mlock.2 @@ -1,4 +1,4 @@ -.\" $NetBSD: mlock.2,v 1.3 1995/06/24 10:42:03 cgd Exp $ +.\" $NetBSD: mlock.2,v 1.4 1997/10/16 23:21:50 christos Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -44,9 +44,9 @@ .Fd #include .Fd #include .Ft int -.Fn mlock "caddr_t addr" "size_t len" +.Fn mlock "void *addr" "size_t len" .Ft int -.Fn munlock "caddr_t addr" "size_t len" +.Fn munlock "void *addr" "size_t len" .Sh DESCRIPTION The .Nm mlock diff --git a/lib/libc/sys/mmap.2 b/lib/libc/sys/mmap.2 index d99b11f5371e..4438813d68ec 100644 --- a/lib/libc/sys/mmap.2 +++ b/lib/libc/sys/mmap.2 @@ -1,4 +1,4 @@ -.\" $NetBSD: mmap.2,v 1.8 1997/07/15 06:47:38 mikel Exp $ +.\" $NetBSD: mmap.2,v 1.9 1997/10/16 23:21:52 christos Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -42,8 +42,8 @@ .Sh SYNOPSIS .Fd #include .Fd #include -.Ft caddr_t -.Fn mmap "caddr_t addr" "size_t len" "int prot" "int flags" "int fd" "off_t offset" +.Ft void * +.Fn mmap "void *addr" "size_t len" "int prot" "int flags" "int fd" "off_t offset" .Sh DESCRIPTION The .Nm mmap diff --git a/lib/libc/sys/mmap.c b/lib/libc/sys/mmap.c index e0e3e2061a3d..ae1a5b198ea7 100644 --- a/lib/libc/sys/mmap.c +++ b/lib/libc/sys/mmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: mmap.c,v 1.7 1997/07/13 20:25:31 christos Exp $ */ +/* $NetBSD: mmap.c,v 1.8 1997/10/16 23:21:55 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)mmap.c 8.1 (Berkeley) 6/17/93"; #else -__RCSID("$NetBSD: mmap.c,v 1.7 1997/07/13 20:25:31 christos Exp $"); +__RCSID("$NetBSD: mmap.c,v 1.8 1997/10/16 23:21:55 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -51,9 +51,9 @@ __RCSID("$NetBSD: mmap.c,v 1.7 1997/07/13 20:25:31 christos Exp $"); * This function provides 64-bit offset padding that * is not supplied by GCC 1.X but is supplied by GCC 2.X. */ -caddr_t +void * mmap(addr, len, prot, flags, fd, offset) - caddr_t addr; + void *addr; size_t len; int prot; int flags; diff --git a/lib/libc/sys/mprotect.2 b/lib/libc/sys/mprotect.2 index 69a3d28defde..dd646bf7c4e7 100644 --- a/lib/libc/sys/mprotect.2 +++ b/lib/libc/sys/mprotect.2 @@ -1,4 +1,4 @@ -.\" $NetBSD: mprotect.2,v 1.6 1995/10/12 15:41:08 jtc Exp $ +.\" $NetBSD: mprotect.2,v 1.7 1997/10/16 23:21:56 christos Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -43,7 +43,7 @@ .Fd #include .Fd #include .Ft int -.Fn mprotect "caddr_t addr" "size_t len" "int prot" +.Fn mprotect "void *addr" "size_t len" "int prot" .Sh DESCRIPTION The .Fn mprotect diff --git a/lib/libc/sys/msync.2 b/lib/libc/sys/msync.2 index 7feb4369ccd8..6ffabfb2aa23 100644 --- a/lib/libc/sys/msync.2 +++ b/lib/libc/sys/msync.2 @@ -1,4 +1,4 @@ -.\" $NetBSD: msync.2,v 1.8 1995/10/12 15:41:09 jtc Exp $ +.\" $NetBSD: msync.2,v 1.9 1997/10/16 23:21:57 christos Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -33,23 +33,24 @@ .\" .\" @(#)msync.2 8.1 (Berkeley) 6/9/93 .\" -.Dd June 9, 1993 +.Dd October 10, 1997 .Dt MSYNC 2 -.Os +.Os NetBSD 1.3 .Sh NAME .Nm msync .Nd synchronize a mapped region .Sh SYNOPSIS -.Fd #include .Fd #include .Ft int -.Fn msync "caddr_t addr" "size_t len" +.Fn msync "void *addr" "size_t len" "int flags" .Sh DESCRIPTION The .Fn msync -system call -writes any modified pages back to the filesystem and updates -the file modification time. +system call writes all pages with shared modifications +in the specified +region of the process's address space back to permanent +storage, and, if requested, invalidates cached data mapped +in the region. If .Fa len is 0, all modified pages within the region containing @@ -57,39 +58,66 @@ is 0, all modified pages within the region containing will be flushed; if .Fa len -is non-zero, only the pages containing +is non-zero, only modified pages containing .Fa addr and .Fa len -succeeding locations will be examined. +succeeding locations will be flushed. Any required synchronization of memory caches will also take place at this time. Filesystem operations on a file that is mapped for shared modifications are unpredictable except after an .Fn msync . +.Pp +The +.Fa flags +argument is formed by +.Em or Ns 'ing +the following values +.Pp +.Bd -literal -offset indent -compact +MS_ASYNC Perform asynchronous writes. +MS_SYNC Perform synchronous writes. +MS_INVALIDATE Invalidate cached data after writing. +.Ed .Sh ERRORS The following errors may be reported: .Bl -tag -width Er +.It Bq Er EBUSY +The +.Dv MS_INVALIDATE +flag was specified and a portion of the specified region +was locked with +.Xr mlock 2 . +.It Bq Er EINVAL +The specified +.Fa flags +argument was invalid. .It Bq Er EINVAL The .Fa addr parameter was not page aligned. -.It Bq Er EINVAL -The -.Fa addr -parameter did not specify an address part of a mapped region. -.It Bq Er EINVAL -The -.Fa len -parameter was negative. .It Bq Er EIO -An I/O error occured while writing to the file system. +An I/O error occured while writing. +.It Bq Er ENOMEM +Addresses in the specified region are outside the range allowed +for the address space of the process, or specify one or more pages +which are unmapped. .Sh SEE ALSO -.Xr madvise 2 , -.Xr munmap 2 , -.Xr mprotect 2 , -.Xr mincore 2 +.Xr mlock 2 , +.Xr mmap 2 , +.Xr munlock 2 +.Sh BUGS +Writes are currently done synchronously even if the +.Dv MS_ASYNC +flag is specified. .Sh HISTORY The .Fn msync -function first appeared in 4.4BSD. +function first appeared in +.Bx 4.4 . +It was modified to conform to +.St -p1003.1b-93 +in +.Nx 1.3 . +.P diff --git a/lib/libc/sys/munmap.2 b/lib/libc/sys/munmap.2 index 7575391c4681..a150b1758ef9 100644 --- a/lib/libc/sys/munmap.2 +++ b/lib/libc/sys/munmap.2 @@ -1,4 +1,4 @@ -.\" $NetBSD: munmap.2,v 1.6 1997/07/15 06:52:43 mikel Exp $ +.\" $NetBSD: munmap.2,v 1.7 1997/10/16 23:21:59 christos Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -43,7 +43,7 @@ .Fd #include .Fd #include .Ft int -.Fn munmap "caddr_t addr" "size_t len" +.Fn munmap "void *addr" "size_t len" .Sh DESCRIPTION The .Fn munmap