From patchwork Fri Nov 19 19:58:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 47952 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6523E385BF85 for ; Fri, 19 Nov 2021 19:59:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6523E385BF85 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1637351979; bh=PZ/+pWF7Fc5IspwalyVk40N9hqQ0Gr5KeiI7clHoQQE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=epok3wZGF9V0Di7HT/E182e5Y4WOEAgwma/sKkcDZqLDIn6T4yXfcm6lqA1sq1p2Z ji/Kg3CFbfiaWTMWz9MQ6GUd77knfrvTDGj0ee01kvj0z13ZSLxKVi0nt/deLGFwh4 nWBTsI14ot/mWKH6lVlBzTX2d+xWaIOyDGI1Nat4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ua1-x936.google.com (mail-ua1-x936.google.com [IPv6:2607:f8b0:4864:20::936]) by sourceware.org (Postfix) with ESMTPS id B61F4385BF99 for ; Fri, 19 Nov 2021 19:58:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B61F4385BF99 Received: by mail-ua1-x936.google.com with SMTP id az37so23449241uab.13 for ; Fri, 19 Nov 2021 11:58:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=PZ/+pWF7Fc5IspwalyVk40N9hqQ0Gr5KeiI7clHoQQE=; b=oteyfSlsdBcnAExbfnzu1M5sP46PUwtQ5Yqq154IHu+UOzVgBQbkFgMNdyXVrB+Xst mKb+D2z+Ar62OHIyanSMRlKu5anXuKj6yOCbNoqekHyLHBaoVj9wfplReYYzWFrrYoTp ebrjJuVtJPnOEaLakjHOqDRUtu5fwVc3dUAC4qnlf4aTF7LoAAt1mKBqTK8Kjy5fS4jG nL1At4cE6nC84DSdm+2rfPuE9PeuSwD5tUZA/8bPbfCKYkgIDg0yoT6dcG64GZQLrPxZ 92DMbONYYbhCGeEIGnKQtnPjx/SU2fQM1Klo1H18pv5TulDGBPLdTCnSsU5BM7AXzFsn fZ6Q== X-Gm-Message-State: AOAM530S/aJW1DBjjj/znlzhz95brhoIiWhOKKb5QmMZYmTo613+4/nO eseGODf/Xa5O+ffaYqLvCB3sgL4gBA3myQ== X-Google-Smtp-Source: ABdhPJxQphQLn4gq+H5i1AV6zWftkThmrecQzJtjw4t+dIh2UA10ptioTn49rWbh1pdFyJ8oNVBo/Q== X-Received: by 2002:a05:6102:3232:: with SMTP id x18mr94026977vsf.38.1637351936088; Fri, 19 Nov 2021 11:58:56 -0800 (PST) Received: from birita.. ([2804:431:c7ca:66dc:bc2c:d33d:22b3:25d7]) by smtp.gmail.com with ESMTPSA id 17sm520884uaq.10.2021.11.19.11.58.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 11:58:55 -0800 (PST) To: libc-alpha@sourceware.org, Stafford Horne Subject: [PATCH] linux: Add generic ioctl implementation Date: Fri, 19 Nov 2021 16:58:52 -0300 Message-Id: <20211119195852.166123-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" The powerpc is refactor to use the default implementation. --- sysdeps/unix/sysv/linux/internal-ioctl.h | 23 +++++++ sysdeps/unix/sysv/linux/ioctl.c | 49 +++++++++++++ .../unix/sysv/linux/powerpc/internal-ioctl.h | 46 +++++++++++++ sysdeps/unix/sysv/linux/powerpc/ioctl.c | 68 ------------------- 4 files changed, 118 insertions(+), 68 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/internal-ioctl.h create mode 100644 sysdeps/unix/sysv/linux/ioctl.c create mode 100644 sysdeps/unix/sysv/linux/powerpc/internal-ioctl.h delete mode 100644 sysdeps/unix/sysv/linux/powerpc/ioctl.c diff --git a/sysdeps/unix/sysv/linux/internal-ioctl.h b/sysdeps/unix/sysv/linux/internal-ioctl.h new file mode 100644 index 0000000000..697b086703 --- /dev/null +++ b/sysdeps/unix/sysv/linux/internal-ioctl.h @@ -0,0 +1,23 @@ +/* Linux internal definitions for ioctl. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +static inline bool +__ioctl_arch (int *r, int fd, unsigned long request, void *arg) +{ + return false; +} diff --git a/sysdeps/unix/sysv/linux/ioctl.c b/sysdeps/unix/sysv/linux/ioctl.c new file mode 100644 index 0000000000..c4855d6302 --- /dev/null +++ b/sysdeps/unix/sysv/linux/ioctl.c @@ -0,0 +1,49 @@ +/* Control device. Linux generic implementation. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#include +#include +#include +#include + +int +__ioctl (int fd, unsigned long int request, ...) +{ + va_list args; + va_start (args, request); + void *arg = va_arg (args, void *); + va_end (args); + + int r; + if (!__ioctl_arch (&r, fd, request, arg)) + { + r = INTERNAL_SYSCALL_CALL (ioctl, fd, request, arg); + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (r))) + { + __set_errno (-r); + return -1; + } + } + return r; +} +libc_hidden_def (__ioctl) +weak_alias (__ioctl, ioctl) + +#if __TIMESIZE != 64 +strong_alias (__ioctl, __ioctl_time64) +#endif diff --git a/sysdeps/unix/sysv/linux/powerpc/internal-ioctl.h b/sysdeps/unix/sysv/linux/powerpc/internal-ioctl.h new file mode 100644 index 0000000000..3a2adce7c3 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/internal-ioctl.h @@ -0,0 +1,46 @@ +/* Linux internal definitions for ioctl. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#include + +static inline bool +__ioctl_arch (int *r, int fd, unsigned long request, void *arg) +{ + switch (request) + { + case TCGETS: + *r = __tcgetattr (fd, (struct termios *) arg); + break; + + case TCSETS: + *r = __tcsetattr (fd, TCSANOW, (struct termios *) arg); + break; + + case TCSETSW: + *r = __tcsetattr (fd, TCSADRAIN, (struct termios *) arg); + break; + + case TCSETSF: + *r = __tcsetattr (fd, TCSAFLUSH, (struct termios *) arg); + break; + + default: + return false; + } + return true; +} diff --git a/sysdeps/unix/sysv/linux/powerpc/ioctl.c b/sysdeps/unix/sysv/linux/powerpc/ioctl.c deleted file mode 100644 index a81c7ba54c..0000000000 --- a/sysdeps/unix/sysv/linux/powerpc/ioctl.c +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (C) 1998-2021 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include -#include - -/* The user-visible size of struct termios has changed. Catch ioctl calls - using the new-style struct termios, and translate them to old-style. */ - -int -__ioctl (int fd, unsigned long int request, ...) -{ - void *arg; - va_list ap; - int result; - - va_start (ap, request); - arg = va_arg (ap, void *); - - switch (request) - { - case TCGETS: - result = __tcgetattr (fd, (struct termios *) arg); - break; - - case TCSETS: - result = __tcsetattr (fd, TCSANOW, (struct termios *) arg); - break; - - case TCSETSW: - result = __tcsetattr (fd, TCSADRAIN, (struct termios *) arg); - break; - - case TCSETSF: - result = __tcsetattr (fd, TCSAFLUSH, (struct termios *) arg); - break; - - default: - result = INLINE_SYSCALL (ioctl, 3, fd, request, arg); - break; - } - - va_end (ap); - - return result; -} -libc_hidden_def (__ioctl) -weak_alias (__ioctl, ioctl) -#if __TIMESIZE != 64 -weak_alias (__ioctl, __ioctl_time64) -#endif