This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: mincore patch


Andreas Jaeger <aj@suse.de> writes:

> you've send me the appended patch while playing around with bounded
> pointers.  Shouldn't this be committed to CVS?

Thanks for reminding me.  (I've moved on to fighting to get BPs into
gcc in recent weeks.)  That patch shouldn't go in--it was just an
interim hack.  Here's one that solves the complete problem:

OK, Uli?

2000-09-08  Greg McGary  <greg@mcgary.org>

	* sysdeps/unix/sysv/linux/syscalls.list (mincore): Fix arg signature.
	* sysdeps/unix/make-syscalls.sh: New signature keyletter `V'.
	* sysdeps/generic/bp-checks.h (CHECK_N_PAGES): New macro.

Index: sysdeps/unix/sysv/linux/syscalls.list
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/syscalls.list,v
retrieving revision 1.80
diff -u -p -r1.80 syscalls.list
--- syscalls.list	2000/07/17 22:28:59	1.80
+++ syscalls.list	2000/09/01 01:52:03
@@ -22,7 +22,7 @@ iopl		-	iopl		i:i	iopl
 klogctl		EXTRA	syslog		i:isi	klogctl
 lchown		-	lchown		i:sii	__lchown	lchown
 madvise		-	madvise		i:pii	posix_madvise	madvise
-mincore		-	mincore		i:iip	mincore
+mincore		-	mincore		i:anV	mincore
 mlock		EXTRA	mlock		i:bn	__mlock	mlock
 mlockall	EXTRA	mlockall	i:i	__mlockall	mlockall
 mmap		-	mmap		b:aniiii	__mmap		mmap
Index: sysdeps/unix/make-syscalls.sh
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/make-syscalls.sh,v
retrieving revision 1.21
diff -u -p -r1.21 make-syscalls.sh
--- make-syscalls.sh	2000/08/17 07:37:00	1.21
+++ make-syscalls.sh	2000/09/01 01:52:03
@@ -21,6 +21,7 @@
 # s: non-NULL string (e.g., 1st arg to open)
 # S: optionally-NULL string (e.g., 1st arg to acct)
 # v: vararg scalar (e.g., optional 3rd arg to open)
+# V: byte-per-page vector (3rd arg to mincore)
 # W: wait status, optionally-NULL pointer to int (e.g., 2nd arg of wait4)
 
 ptr='[abBfFINpPsSW]'	# all pointer keyletters
@@ -232,7 +233,7 @@ shared-only-routines += $file
     # generate extern decls of dummy variables for each arg
     echo "	 echo '`echo $args | \
 	    sed -e 's/<\('$typ'[1-9]\)>/extern \1, \1v;/g' \
-		-e 's/<\([abBFIsS][1-9]\)>/extern char \1v;/g' \
+		-e 's/<\([abBFIsSV][1-9]\)>/extern char \1v;/g' \
 		-e 's/<\([Wv][1-9]\)>/extern int \1v;/g'` \\'; \\"
 
     # generate bounded-pointer thunk declarator
@@ -255,6 +256,7 @@ shared-only-routines += $file
 	    sed -e 's/<b0>/BOUNDED_N (/' \
 		-e 's/<.0>//'`($callname) (`echo $arglist | \
 	    sed -e 's/<\(a[1-9]\)>/__ptrvalue (\1a)/g' \
+		-e 's/<\(n[1-9]\)>, <\(V[1-9]\)>/\1a, CHECK_N_PAGES (\2a, \1a)/g' \
 		-e 's/<\(b[1-9]\)>, <\(n[1-9]\)>/CHECK_N (\1a, \2a), \2a/g' \
 		-e 's/<\(b[1-9]\)>, <\(N[1-9]\)>/CHECK_N (\1a, *CHECK_1 (\2a)), __ptrvalue (\2a)/g' \
 		-e 's/<\(B[1-9]\)>, <\(n[1-9]\)>/CHECK_N_NULL_OK (\1a, \2a), \2a/g' \
Index: sysdeps/generic/bp-checks.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/generic/bp-checks.h,v
retrieving revision 1.6
diff -u -p -r1.6 bp-checks.h
--- bp-checks.h	2000/08/17 07:37:00	1.6
+++ bp-checks.h	2000/09/08 08:14:44
@@ -90,6 +90,13 @@ extern void *__unbounded __ubp_memchr (c
   (((CMD) == F_GETLK || (CMD) == F_SETLK || (CMD) == F_SETLKW)	\
    ? CHECK_1 ((struct flock *) ARG) : (unsigned long) (ARG))
 
+/* Check bounds of an array of mincore residency-status flags that
+   cover a region of NBYTES.  Such a vector occupies one byte per page
+   of memory.  */
+# define CHECK_N_PAGES(ARG, NBYTES)					\
+  ({ int _page_size_ = sysconf (_SC_PAGE_SIZE);				\
+     CHECK_N ((ARG), ((NBYTES) + _page_size_ - 1) / _page_size_); })
+
 /* Return a bounded pointer with value PTR that satisfies CHECK_N (PTR, N).  */
 # define BOUNDED_N(PTR, N) 				\
   ({ __typeof (PTR) __bounded _p_;			\
@@ -113,6 +120,7 @@ extern void *__unbounded __ubp_memchr (c
 # define CHECK_SIGSET_NULL_OK(SET) (SET)
 # define CHECK_IOCTL(ARG, CMD) (ARG)
 # define CHECK_FCNTL(ARG, CMD) (ARG)
+# define CHECK_N_PAGES(ARG, NBYTES) (ARG)
 # define BOUNDED_N(PTR, N) (PTR)
 
 #endif /* !__BOUNDED_POINTERS__ */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]