public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: linux-kernel@vger.kernel.org
Cc: linux-arch@vger.kernel.org, Jeff Dike <jdike@addtoit.com>,
	Bjoern Steinbrink <B.Steinbrink@gmx.de>,
	Arjan van de Ven <arjan@infradead.org>,
	Chase Venters <chase.venters@clientec.com>,
	Andrew Morton <akpm@osdl.org>,
	David Howells <dhowells@redhat.com>, Andi Kleen <ak@suse.de>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: [PATCH 4/6] Remove the use of _syscallX macros in UML
Date: Wed, 30 Aug 2006 14:44:00 +0200	[thread overview]
Message-ID: <20060830125037.958748000@klappe.arndb.de> (raw)
In-Reply-To: 20060830124356.567568000@klappe.arndb.de

[-- Attachment #1: uml-syscalls.diff --]
[-- Type: text/plain, Size: 4694 bytes --]

User mode linux uses _syscallX() to call into the host kernel.
The recommended way to do this is to use the syscall() function
from libc.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Index: linux-cg/arch/um/os-Linux/process.c
===================================================================
--- linux-cg.orig/arch/um/os-Linux/process.c	2006-08-30 14:29:07.000000000 +0200
+++ linux-cg/arch/um/os-Linux/process.c	2006-08-30 14:31:40.000000000 +0200
@@ -12,6 +12,7 @@
 #include <sys/mman.h>
 #include <sys/wait.h>
 #include <sys/mman.h>
+#include <sys/syscall.h>
 #include "ptrace_user.h"
 #include "os.h"
 #include "user.h"
@@ -141,11 +142,9 @@
  * syscalls, and also breaks with clone(), which does not unshare the TLS.
  */
 
-inline _syscall0(pid_t, getpid)
-
 int os_getpid(void)
 {
-	return(getpid());
+	return(syscall(__NR_getpid));
 }
 
 int os_getpgrp(void)
Index: linux-cg/arch/um/os-Linux/sys-i386/tls.c
===================================================================
--- linux-cg.orig/arch/um/os-Linux/sys-i386/tls.c	2006-08-30 14:29:07.000000000 +0200
+++ linux-cg/arch/um/os-Linux/sys-i386/tls.c	2006-08-30 14:31:40.000000000 +0200
@@ -1,10 +1,9 @@
 #include <errno.h>
 #include <linux/unistd.h>
+#include <sys/syscall.h>
 #include "sysdep/tls.h"
 #include "user_util.h"
 
-static _syscall1(int, get_thread_area, user_desc_t *, u_info);
-
 /* Checks whether host supports TLS, and sets *tls_min according to the value
  * valid on the host.
  * i386 host have it == 6; x86_64 host have it == 12, for i386 emulation. */
@@ -17,7 +16,7 @@
 		user_desc_t info;
 		info.entry_number = val[i];
 
-		if (get_thread_area(&info) == 0) {
+		if (syscall(__NR_get_thread_area, &info) == 0) {
 			*tls_min = val[i];
 			*supports_tls = 1;
 			return;
Index: linux-cg/arch/um/os-Linux/tls.c
===================================================================
--- linux-cg.orig/arch/um/os-Linux/tls.c	2006-08-30 14:29:07.000000000 +0200
+++ linux-cg/arch/um/os-Linux/tls.c	2006-08-30 14:31:40.000000000 +0200
@@ -1,5 +1,6 @@
 #include <errno.h>
 #include <sys/ptrace.h>
+#include <sys/syscall.h>
 #include <asm/ldt.h>
 #include "sysdep/tls.h"
 #include "uml-config.h"
@@ -48,14 +49,11 @@
 #ifdef UML_CONFIG_MODE_TT
 #include "linux/unistd.h"
 
-static _syscall1(int, get_thread_area, user_desc_t *, u_info);
-static _syscall1(int, set_thread_area, user_desc_t *, u_info);
-
 int do_set_thread_area_tt(user_desc_t *info)
 {
 	int ret;
 
-	ret = set_thread_area(info);
+	ret = syscall(__NR_set_thread_area,info);
 	if (ret < 0) {
 		ret = -errno;
 	}
@@ -66,7 +64,7 @@
 {
 	int ret;
 
-	ret = get_thread_area(info);
+	ret = syscall(__NR_get_thread_area,info);
 	if (ret < 0) {
 		ret = -errno;
 	}
Index: linux-cg/arch/um/sys-i386/unmap.c
===================================================================
--- linux-cg.orig/arch/um/sys-i386/unmap.c	2006-08-30 14:29:07.000000000 +0200
+++ linux-cg/arch/um/sys-i386/unmap.c	2006-08-30 14:31:40.000000000 +0200
@@ -5,20 +5,17 @@
 
 #include <linux/mman.h>
 #include <asm/unistd.h>
+#include <sys/syscall.h>
 
-static int errno;
-
-static inline _syscall2(int,munmap,void *,start,size_t,len)
-static inline _syscall6(void *,mmap2,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
 int switcheroo(int fd, int prot, void *from, void *to, int size)
 {
-	if(munmap(to, size) < 0){
+	if (syscall(__NR_munmap, to, size) < 0){
 		return(-1);
 	}
-	if(mmap2(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1 ){
+	if (syscall(__NR_mmap2, to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1 ){
 		return(-1);
 	}
-	if(munmap(from, size) < 0){
+	if (syscall(__NR_munmap, from, size) < 0){
 		return(-1);
 	}
 	return(0);
Index: linux-cg/arch/um/sys-x86_64/unmap.c
===================================================================
--- linux-cg.orig/arch/um/sys-x86_64/unmap.c	2006-08-30 14:29:07.000000000 +0200
+++ linux-cg/arch/um/sys-x86_64/unmap.c	2006-08-30 14:34:50.000000000 +0200
@@ -5,20 +5,17 @@
 
 #include <linux/mman.h>
 #include <asm/unistd.h>
+#include <sys/syscall.h>
 
-static int errno;
-
-static inline _syscall2(int,munmap,void *,start,size_t,len)
-static inline _syscall6(void *,mmap,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
 int switcheroo(int fd, int prot, void *from, void *to, int size)
 {
-	if(munmap(to, size) < 0){
+	if (syscall(__NR_munmap, to, size) < 0){
 		return(-1);
 	}
-	if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1){
+	if (syscall(__NR_mmap, to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1){
 		return(-1);
 	}
-	if(munmap(from, size) < 0){
+	if (syscall(__NR_munmap, from, size) < 0){
 		return(-1);
 	}
 	return(0);

--


  parent reply	other threads:[~2006-08-30 12:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-30 12:43 [PATCH 0/6] kill __KERNEL_SYSCALLS__, try #3 Arnd Bergmann
2006-08-30 12:43 ` [PATCH 1/6] introduce kernel_execve Arnd Bergmann
2006-08-30 12:43 ` [PATCH 2/6] rename the provided execve functions to kernel_execve Arnd Bergmann
2006-08-30 21:47   ` Paul Mackerras
2006-08-30 12:43 ` [PATCH 3/6] provide kernel_execve on all architectures Arnd Bergmann
2006-08-30 14:16   ` Martin Schwidefsky
2006-08-30 12:44 ` Arnd Bergmann [this message]
2006-08-30 12:44 ` [PATCH 5/6] sh64: remove the use of kernel syscalls Arnd Bergmann, Paul Mundt
2006-08-30 13:11   ` Arnd Bergmann
2006-08-30 12:44 ` [PATCH 6/6] remove remaining errno and __KERNEL_SYSCALLS__ references Arnd Bergmann
2006-08-30 13:12 ` [PATCH 0/6] kill __KERNEL_SYSCALLS__, try #3 David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060830125037.958748000@klappe.arndb.de \
    --to=arnd@arndb.de \
    --cc=B.Steinbrink@gmx.de \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=arjan@infradead.org \
    --cc=chase.venters@clientec.com \
    --cc=dhowells@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jdike@addtoit.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox