From owner-freebsd-arch@FreeBSD.ORG Sun Aug 28 12:34:22 2011 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A6E6D1065672 for ; Sun, 28 Aug 2011 12:34:22 +0000 (UTC) (envelope-from kmacybsd@gmail.com) Received: from mail-vx0-f182.google.com (mail-vx0-f182.google.com [209.85.220.182]) by mx1.freebsd.org (Postfix) with ESMTP id 696548FC0A for ; Sun, 28 Aug 2011 12:34:22 +0000 (UTC) Received: by vxh11 with SMTP id 11so4755246vxh.13 for ; Sun, 28 Aug 2011 05:34:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; bh=KtggdQlFi8TTbMMTGTG4mOB4Nd31yFrK/UidSGbed14=; b=OJuGLVRJg+jjQgE3aMXojSDvIGF+d0P1MavDpDHb5US2mSLYDtLg3+kTmN0eIYTO7X 6SvmBfWdYDsVs7r2sQsDv7iLsnlQrbORfRnx/7pyAjAKzX767Zt1wa/AxvkX2tkzNK8E NAeeiqameuSYfxA1AAUfXLNWlZXf0Y1B6e840= MIME-Version: 1.0 Received: by 10.220.115.205 with SMTP id j13mr1010671vcq.136.1314533116908; Sun, 28 Aug 2011 05:05:16 -0700 (PDT) Sender: kmacybsd@gmail.com Received: by 10.52.186.163 with HTTP; Sun, 28 Aug 2011 05:05:16 -0700 (PDT) Date: Sun, 28 Aug 2011 14:05:16 +0200 X-Google-Sender-Auth: ACptGEbjTx8f31inLoD2WVJ7sJI Message-ID: From: "K. Macy" To: arch@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Cc: Subject: Prefixing system calls to eliminate namespace collisions between kernel and libc X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Aug 2011 12:34:22 -0000 This change was motivated by a library that I have written which is, in effect, a run-time environment for running the freebsd kernel network stack in userspace. With the exception of a small change to makesyscalls.sh, this change is entirely mechanical. All non-compatibility kernel entry points (e.g. not linux_, freebsd32_, freebsd6_, etc.) are prefixed with sys_ to eliminate collisions between system call implementations and their libc names. NetBSD long ago made this change as well. and for linux this may always have been the case. Linking POSIX programs against parts of the kernel can actually be done just by mangling things during dynamic linking, so doesn't require the above, but it is certainly easier and more portable with the above. Ultimately I would like my userspace network stack to be able to run on windows as well. I don't think that I have the same flexibility there with regards to linker scripts. My userspace stack could ease networking code development by allowing initial work to take place in userspace. syscalls.master is unchanged: 97 AUE_SOCKET STD { int socket(int domain, int type, \ int protocol); } Only the source function changes name: diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 0e5efe6..3b83e1c 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -171,7 +171,7 @@ getsock_cap(struct filedesc *fdp, int fd, cap_rights_t rights, #endif int -socket(td, uap) +sys_socket(td, uap) struct thread *td; struct socket_args /* { int domain; @@ -210,7 +210,7 @@ socket(td, uap) Please see: http://pastebin.com/PpC5uThs