From patchwork Thu Dec 14 06:29:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 848380 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=uclibc-ng.org (client-ip=89.238.66.15; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="UISiR4Uj"; dkim-atps=neutral Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yy3Yv5jG7z9s83 for ; Thu, 14 Dec 2017 17:29:23 +1100 (AEDT) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id B80F810746; Thu, 14 Dec 2017 07:29:20 +0100 (CET) X-Original-To: devel@uclibc-ng.org Delivered-To: devel@helium.openadk.org Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by helium.openadk.org (Postfix) with ESMTPS id 00A08106F9 for ; Thu, 14 Dec 2017 07:29:18 +0100 (CET) Received: by mail-pf0-f195.google.com with SMTP id j28so2972941pfk.8 for ; Wed, 13 Dec 2017 22:29:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v/3OiQl0tdMLdQTdyajcgJcCsVLazK4ygJg7guHdiQY=; b=UISiR4UjXoglz1AMHu9rLAHYU7oX6fIldkCHAwHxnY2GLKF/VE7DTrPm1WXeeXu7/v TexEv4ZFn4nr3S/eNX1VVn5lT4s7yCWJV78IZZ30bxzHTbrlHyXJxgvHaozg3g58MACo yBD6k4IQ6WsgPbTdByK8D61DV0gaaPvKnSajUbklMkMAo/sY8CZp5hsqGSrzfDi0A5io H8zQ7XwXtcWAgMMJDGAMwVsHeVbEUbDoBu27fmiTYypmuz4SXt3mcqDo8Q2V83Lv0VcU jhc5zN1cUJdO44PwGOJURSomQzTkV4ie/ytkWPMTQve+yYJ7Jzj+bhGzsRR7etBvWi0G +bAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v/3OiQl0tdMLdQTdyajcgJcCsVLazK4ygJg7guHdiQY=; b=BcCfY06mQ5DSpLJ+iNyQ3Kz1pMQbHAGyiLxnpRlayEBEBcK1iYGQfWok2fOMaXssIX mRS6c6S5QzP69i6wSHBOLXLzS4A1dT50mvQsv5AYo65HYtaPQrPn3PZZONAxHYroku9D JTgBMiXfIQ4qcVUAFZfATc2XUOZzbmDiHlj5Mf4yrdskfSuCla7z8LJQ1p3bFOmXeOpK aBtt4KrM3q3YAKN/kmzVMY1Z/5bXmq/ni7SnJX1yavKrSPatMK02aGJ3t6MkK37NmAn1 Rn+laEOzAncoPZ6+GxgOCc3Uspf9yzGlEC08HEVURf5gNUfUwTgJMD7ELltzrmpxUJUt vB2g== X-Gm-Message-State: AKGB3mLEr7D9Wzm7nQmSzyMjh58JqgIeYFxs7Uw9hsmVp8y7zt1jmOb4 d5D4RiTFPpM2PeI5DtaHEW9HyN8v X-Google-Smtp-Source: ACJfBougF5tOS/HZVjJPTig7rZDTOUWhkI84D564joQFAkV6h07sWON/XH+0lQYFiaWvcqBqGlcsAg== X-Received: by 10.84.169.36 with SMTP id g33mr8261830plb.83.1513232956305; Wed, 13 Dec 2017 22:29:16 -0800 (PST) Received: from localhost (g41.219-103-184.ppp.wakwak.ne.jp. [219.103.184.41]) by smtp.gmail.com with ESMTPSA id b10sm6103535pfj.20.2017.12.13.22.29.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Dec 2017 22:29:15 -0800 (PST) From: Stafford Horne To: uclibc-ng Devel Date: Thu, 14 Dec 2017 15:29:06 +0900 Message-Id: <20171214062909.8602-2-shorne@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171214062909.8602-1-shorne@gmail.com> References: <20171214062909.8602-1-shorne@gmail.com> Subject: [uclibc-ng-devel] [PATCH 1/4] syscall: Make common implementation match unistd.h X-BeenThere: devel@uclibc-ng.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: uClibc-ng Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: devel-bounces@uclibc-ng.org Sender: "devel" The definition of syscall() in unistd.h is with varargs. Traditionally the common implementation in uclibc has been with regular arguments. This patch updates that by using varargs. This has caused issues on architectures like or1k which have different calling conventions for varargs and regular arg parameters. The implementation here is based on an implementation from Joel Stanley . There is a difference that I do not initialize the stack args with 0 as they are immediately overwritten by va_args. Signed-off-by: Stafford Horne --- libc/sysdeps/linux/common/syscall.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libc/sysdeps/linux/common/syscall.c b/libc/sysdeps/linux/common/syscall.c index 61f798e2c..d173d2c54 100644 --- a/libc/sysdeps/linux/common/syscall.c +++ b/libc/sysdeps/linux/common/syscall.c @@ -4,9 +4,25 @@ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ +#include #include +#include -long syscall(long sysnum, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6) +long syscall(long sysnum, ...) { + + unsigned long arg1, arg2, arg3, arg4, arg5, arg6; + va_list arg; + + va_start (arg, sysnum); + arg1 = va_arg (arg, unsigned long); + arg2 = va_arg (arg, unsigned long); + arg3 = va_arg (arg, unsigned long); + arg4 = va_arg (arg, unsigned long); + arg5 = va_arg (arg, unsigned long); + arg6 = va_arg (arg, unsigned long); + va_end (arg); + + __asm__ volatile ( "" ::: "memory" ); return INLINE_SYSCALL_NCS(sysnum, 6, arg1, arg2, arg3, arg4, arg5, arg6); }