From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Rob Browning Newsgroups: gmane.lisp.guile.devel Subject: [PATCH 6/8] _helpers: remove vestigial py2 utimes related code Date: Tue, 30 May 2023 19:49:42 -0500 Message-ID: <20230531004944.1657633-7-rlb@defaultvalue.org> References: <20230531004944.1657633-1-rlb@defaultvalue.org> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18716"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Wed May 31 02:51:03 2023 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q4A3L-0004cC-Iy for guile-devel@m.gmane-mx.org; Wed, 31 May 2023 02:51:03 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4A2D-0006Ll-JO; Tue, 30 May 2023 20:49:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4A2C-0006LK-Hm for guile-devel@gnu.org; Tue, 30 May 2023 20:49:52 -0400 Original-Received: from defaultvalue.org ([45.33.119.55]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4A29-0008Ec-MA for guile-devel@gnu.org; Tue, 30 May 2023 20:49:52 -0400 Original-Received: from trouble.defaultvalue.org (localhost [127.0.0.1]) (Authenticated sender: rlb@defaultvalue.org) by defaultvalue.org (Postfix) with ESMTPSA id 1F58720664 for ; Tue, 30 May 2023 19:49:46 -0500 (CDT) Original-Received: by trouble.defaultvalue.org (Postfix, from userid 1000) id 1A98F14E0A8; Tue, 30 May 2023 19:49:45 -0500 (CDT) X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230531004944.1657633-1-rlb@defaultvalue.org> Received-SPF: pass client-ip=45.33.119.55; envelope-from=rlb@defaultvalue.org; helo=defaultvalue.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:21846 Archived-At: Signed-off-by: Rob Browning Tested-by: Rob Browning --- lib/bup/_helpers.c | 180 --------------------------------------------- 1 file changed, 180 deletions(-) diff --git a/lib/bup/_helpers.c b/lib/bup/_helpers.c index 2ca4ef839..9bfb5e35a 100644 --- a/lib/bup/_helpers.c +++ b/lib/bup/_helpers.c @@ -73,20 +73,6 @@ #define BUP_HAVE_FILE_ATTRS 1 #endif -#if PY_MAJOR_VERSION > 2 -# define BUP_USE_PYTHON_UTIME 1 -#endif - -#ifndef BUP_USE_PYTHON_UTIME // just for Python 2 now -/* - * Check for incomplete UTIMENSAT support (NetBSD 6), and if so, - * pretend we don't have it. - */ -#if !defined(AT_FDCWD) || !defined(AT_SYMLINK_NOFOLLOW) -#undef HAVE_UTIMENSAT -#endif -#endif // defined BUP_USE_PYTHON_UTIME - #ifndef FS_NOCOW_FL // Of course, this assumes it's a bitfield value. #define FS_NOCOW_FL 0 @@ -1106,138 +1092,6 @@ static PyObject *bup_set_linux_file_attr(PyObject *self, PyObject *args) #endif /* def BUP_HAVE_FILE_ATTRS */ -#ifndef BUP_USE_PYTHON_UTIME // just for Python 2 now -#ifndef HAVE_UTIMENSAT -#ifndef HAVE_UTIMES -#error "cannot find utimensat or utimes()" -#endif -#ifndef HAVE_LUTIMES -#error "cannot find utimensat or lutimes()" -#endif -#endif -#endif // defined BUP_USE_PYTHON_UTIME - -#ifndef BUP_USE_PYTHON_UTIME // just for Python 2 now -#ifdef HAVE_UTIMENSAT - -static PyObject *bup_utimensat(PyObject *self, PyObject *args) -{ - int rc; - int fd, flag; - char *path; - PyObject *access_py, *modification_py; - struct timespec ts[2]; - - if (!PyArg_ParseTuple(args, "i" cstr_argf "((Ol)(Ol))i", - &fd, - &path, - &access_py, &(ts[0].tv_nsec), - &modification_py, &(ts[1].tv_nsec), - &flag)) - return NULL; - - int overflow; - if (!BUP_ASSIGN_PYLONG_TO_INTEGRAL(&(ts[0].tv_sec), access_py, &overflow)) - { - if (overflow) - PyErr_SetString(PyExc_ValueError, - "unable to convert access time seconds for utimensat"); - return NULL; - } - if (!BUP_ASSIGN_PYLONG_TO_INTEGRAL(&(ts[1].tv_sec), modification_py, &overflow)) - { - if (overflow) - PyErr_SetString(PyExc_ValueError, - "unable to convert modification time seconds for utimensat"); - return NULL; - } - rc = utimensat(fd, path, ts, flag); - if (rc != 0) - return PyErr_SetFromErrnoWithFilename(PyExc_OSError, path); - - return Py_BuildValue("O", Py_None); -} - -#endif /* def HAVE_UTIMENSAT */ - - -#if defined(HAVE_UTIMES) || defined(HAVE_LUTIMES) - -static int bup_parse_xutimes_args(char **path, - struct timeval tv[2], - PyObject *args) -{ - PyObject *access_py, *modification_py; - long long access_us, modification_us; // POSIX guarantees tv_usec is signed. - - if (!PyArg_ParseTuple(args, cstr_argf "((OL)(OL))", - path, - &access_py, &access_us, - &modification_py, &modification_us)) - return 0; - - int overflow; - if (!BUP_ASSIGN_PYLONG_TO_INTEGRAL(&(tv[0].tv_sec), access_py, &overflow)) - { - if (overflow) - PyErr_SetString(PyExc_ValueError, "unable to convert access time seconds to timeval"); - return 0; - } - if (!INTEGRAL_ASSIGNMENT_FITS(&(tv[0].tv_usec), access_us)) - { - PyErr_SetString(PyExc_ValueError, "unable to convert access time nanoseconds to timeval"); - return 0; - } - if (!BUP_ASSIGN_PYLONG_TO_INTEGRAL(&(tv[1].tv_sec), modification_py, &overflow)) - { - if (overflow) - PyErr_SetString(PyExc_ValueError, "unable to convert modification time seconds to timeval"); - return 0; - } - if (!INTEGRAL_ASSIGNMENT_FITS(&(tv[1].tv_usec), modification_us)) - { - PyErr_SetString(PyExc_ValueError, "unable to convert modification time nanoseconds to timeval"); - return 0; - } - return 1; -} - -#endif /* defined(HAVE_UTIMES) || defined(HAVE_LUTIMES) */ - - -#ifdef HAVE_UTIMES -static PyObject *bup_utimes(PyObject *self, PyObject *args) -{ - char *path; - struct timeval tv[2]; - if (!bup_parse_xutimes_args(&path, tv, args)) - return NULL; - int rc = utimes(path, tv); - if (rc != 0) - return PyErr_SetFromErrnoWithFilename(PyExc_OSError, path); - return Py_BuildValue("O", Py_None); -} -#endif /* def HAVE_UTIMES */ - - -#ifdef HAVE_LUTIMES -static PyObject *bup_lutimes(PyObject *self, PyObject *args) -{ - char *path; - struct timeval tv[2]; - if (!bup_parse_xutimes_args(&path, tv, args)) - return NULL; - int rc = lutimes(path, tv); - if (rc != 0) - return PyErr_SetFromErrnoWithFilename(PyExc_OSError, path); - - return Py_BuildValue("O", Py_None); -} -#endif /* def HAVE_LUTIMES */ - -#endif // defined BUP_USE_PYTHON_UTIME - - #ifdef HAVE_STAT_ST_ATIM # define BUP_STAT_ATIME_NS(st) (st)->st_atim.tv_nsec # define BUP_STAT_MTIME_NS(st) (st)->st_mtim.tv_nsec @@ -2056,23 +1910,6 @@ static PyMethodDef helper_methods[] = { { "set_linux_file_attr", bup_set_linux_file_attr, METH_VARARGS, "Set the Linux attributes for the given file." }, #endif - -#ifndef BUP_USE_PYTHON_UTIME // just for Python 2 now -#ifdef HAVE_UTIMENSAT - { "bup_utimensat", bup_utimensat, METH_VARARGS, - "Change path timestamps with nanosecond precision (POSIX)." }, -#endif -#ifdef HAVE_UTIMES - { "bup_utimes", bup_utimes, METH_VARARGS, - "Change path timestamps with microsecond precision." }, -#endif -#ifdef HAVE_LUTIMES - { "bup_lutimes", bup_lutimes, METH_VARARGS, - "Change path timestamps with microsecond precision;" - " don't follow symlinks." }, -#endif -#endif // defined BUP_USE_PYTHON_UTIME - { "stat", bup_stat, METH_VARARGS, "Extended version of stat." }, { "lstat", bup_lstat, METH_VARARGS, @@ -2208,23 +2045,6 @@ static int setup_module(PyObject *m) Py_DECREF(value); } -#ifndef BUP_USE_PYTHON_UTIME // just for Python 2 now -#ifdef HAVE_UTIMENSAT - { - PyObject *value; - value = BUP_LONGISH_TO_PY(AT_FDCWD); - PyObject_SetAttrString(m, "AT_FDCWD", value); - Py_DECREF(value); - value = BUP_LONGISH_TO_PY(AT_SYMLINK_NOFOLLOW); - PyObject_SetAttrString(m, "AT_SYMLINK_NOFOLLOW", value); - Py_DECREF(value); - value = BUP_LONGISH_TO_PY(UTIME_NOW); - PyObject_SetAttrString(m, "UTIME_NOW", value); - Py_DECREF(value); - } -#endif -#endif // defined BUP_USE_PYTHON_UTIME - #ifdef BUP_HAVE_MINCORE_INCORE { PyObject *value; -- 2.39.2