From owner-freebsd-hackers@freebsd.org Fri Mar 16 17:01:08 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5DBF8F5E0F6 for ; Fri, 16 Mar 2018 17:01:08 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-lf0-x22a.google.com (mail-lf0-x22a.google.com [IPv6:2a00:1450:4010:c07::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BF822697CD; Fri, 16 Mar 2018 17:01:07 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-lf0-x22a.google.com with SMTP id z143-v6so10116563lff.3; Fri, 16 Mar 2018 10:01:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to; bh=4gvXK8bHgF8Yz4oagJ/GcI0mMCowGON+97osrn1RVBM=; b=vX6Ki6W8eXMtW030BGv5YBRn61F9UNdL80yutN+JdiwBGEH3WAMzWdwKIKJED17ejq Zt0N5Uvytr1C0P0FCz1MtoT3WEmzVwm2MsYyuuuMtxw4vjBUjMmAFhNx9vskjjgbslb0 QQnZo3qlaT1k+RSXrfAhMCWYFFVme/j8f6hz1CJJ9tY5Ju9fLUdPFkiLcD3tnY/NBbdj SY8IRXHVBOeja9AZMAgVZZdoa8PnZBfB8EeacudBjc0Bk5mryeLyHdc5+1E4O3LMnyxo ZtLRWszaG2PPvWR3WcfNiEgE557mcs2ZkhxoqnibRmqg+Zs8LxQTimKfl2Yhxlk7M4Oy GDrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=4gvXK8bHgF8Yz4oagJ/GcI0mMCowGON+97osrn1RVBM=; b=j45MoQUmMPeOGFAlxUU2mGto+r2HjxFS1FPiQSfNQFYjJaZ39CjmRjmy1UdKASxAV0 sVdgLjBb/mNEPy9YYVXnW6N4o/Trpb5bxwiolsTH8n3EjwZh3Q4smTbE9G5wc6AeLSIN Q1nLWc6A1hm4ALovRDB3bBSNcR/0I7Niuw5HkaeKk/zsRPCB+I2aGOBKI+hlZkm3KYNO rpQibKHEVWzZblQIWpqG7tPtVllvqSWYFiGL6uhmgvJSe5zueISkGcGHkZrKMwaY8W3F 6fICU/GxWyFJ1pjiEj6ci27rNnIK1+2KwEayvvc3GCSRkZN9teedXaOnyBq+zxGkCUH7 kH+w== X-Gm-Message-State: AElRT7FITHyvj6CwGeVXZ3NGZdws1wrtrygnU3xZ6SIjKF9PujoIWKsh 7y95Dk+oLG25pyE0cudE/QDWOg047jnWGsuvUyLmEg== X-Google-Smtp-Source: AG47ELuo0W52qufYrgtVLqFhKuYei2ydlqEINDdmQLB6DVZ+xQZjWkQnkJjpY6CCwBaheBxkw2y5OZHlGvsVuqL19qE= X-Received: by 2002:a19:14d1:: with SMTP id 78-v6mr1982210lfu.37.1521219665868; Fri, 16 Mar 2018 10:01:05 -0700 (PDT) MIME-Version: 1.0 Sender: asomers@gmail.com Received: by 10.179.3.226 with HTTP; Fri, 16 Mar 2018 10:01:04 -0700 (PDT) From: Alan Somers Date: Fri, 16 Mar 2018 11:01:04 -0600 X-Google-Sender-Auth: e4xvbtD7F1bVWsPLMXT9Nn9LvOE Message-ID: Subject: Is it time to expose timespecsub and friends to userland? To: FreeBSD Hackers , bde@freebsd.org, Poul-Henning Kamp Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Mar 2018 17:01:08 -0000 There are at least 19 system calls that have timeout arguments specified as struct timespec [1]. "struct stat" describes file timestamps as timespecs as well [2]. setsockopt(2), sched_rr_get_interval(2), geom_stats_snapshot_timestamp(3) and pmclog_read(3) use timespecs for other purposes. The sysctl node kern.crypto_stats exposes timespecs. sudo records timespecs in its timestamp files. Who know how many other ports do something similar; I'm not going to grep them all. And yet, FreeBSD provides no way to manipulate this structure. Every program that uses them has to roll its own version of pretty much the same functions. NetBSD does [3], and has for a long time. In fact, NetBSD's timespecsub is old enough to drink [4]. But in FreeBSD, those functions languish inside of an "#ifdef KERNEL". phk added them in r35029 with the comment "XXX: These may change!". But it's been nearly 20 years, so I don't think they're going to change any more. Shall we finally expose them to userland and add a man page? Let the bikeshed begin! If the flame isn't too bad, I'll do it. -Alan [1] syscalls that use timespec timeouts include: aio_suspend(2), aio_waitcomplete(2), nanosleep(2), clock_nanosleep(2), kevent(2), mq_timedreceive(2), mq_timedsend(2), ppoll(2), pselect(2), recvmmsg(2), sigtimedwait(2), thr_suspend(2), cnd_timedwait(3), mtx_timedlock(3), thrd_sleep(3), pthread_mutex_timedlock(3), pthread_cond_timedwait(3), sem_timedwait(3), sem_clockwait_np(3). [2] syscalls that use timespecs for file timestamp related purposes: stat(2), fstat(2), futimens(2), utimensat(2), lstat(2) [3] http://netbsd.gw.com/cgi-bin/man-cgi?timespecclear+3+NetBSD-7.0 [4] http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/time.h.diff?r1=1.19&r2=1.20&only_with_tag=MAIN&f=h