From patchwork Sun Jan 28 16:07:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 866841 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-89728-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="TQBiUlBc"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zTyGQ6D3xz9sNc for ; Mon, 29 Jan 2018 03:07:42 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=XRpSIFtm6Xu9mTVb29wYgUZzJuuvf3/hR6ZrA4s2Nce9atw5CmNqA LuP5Z8CPXw01S52FS8hzl1fl5kB6rLlcmIxkOGG40hPbEyNFInM7bUaRCY/pUCLP +35RlGM7YTUlN10HNWcSKr6zi3GN7Mt1VpqQekSbbmHjMhK7cQ7c94= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=O8W8cLutIe6SJRtVESTZ+E62R7k=; b=TQBiUlBcrQX9dpr3izhTVNfAxu07 icSfHsirEJYYxqHmY6vGcgwroX+hcMCH5dxfsLaiiVTT1zQBQyU1NJYTngMNmDeb CuQQxlHfsxoLluu1ASHjXv5pt0qrrpSTnFJaZIxdWRmbd3Uzx1pwQig6SWBvPlsI bHYoVFeDV4foquY= Received: (qmail 60261 invoked by alias); 28 Jan 2018 16:07:37 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 60251 invoked by uid 89); 28 Jan 2018 16:07:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.2 spammy= X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Thomas Schwinge Subject: [hurd,commited] hurd: Add missing fcntl-internal.h Date: Sun, 28 Jan 2018 17:07:29 +0100 Message-Id: <20180128160729.22510-1-samuel.thibault@ens-lyon.org> From: Thomas Schwinge * hurd/fcntl-internal.h: New file. --- ChangeLog | 4 ++++ hurd/fcntl-internal.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 hurd/fcntl-internal.h diff --git a/ChangeLog b/ChangeLog index 49bdd47601..434fef785d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -52,6 +52,10 @@ * sysdeps/mach/hurd/check_native.c: New file. * sysdeps/mach/hurd/check_pf.c: New file. +2008-12-18 Thomas Schwinge + + * hurd/fcntl-internal.h: New file. + 2018-01-27 James Clarke * sysdeps/hppa/fpu/libm-test-ulps: Update. diff --git a/hurd/fcntl-internal.h b/hurd/fcntl-internal.h new file mode 100644 index 0000000000..d795e4089c --- /dev/null +++ b/hurd/fcntl-internal.h @@ -0,0 +1,62 @@ +/* Helper functions for translating between O_* and SOCK_* flags. + Copyright (C) 2008-2018 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 + +/* Do some compile-time checks for the SOCK_* constants, which we rely on. */ +_Static_assert (SOCK_CLOEXEC == O_CLOEXEC, + "SOCK_CLOEXEC is assumed to be the same as O_CLOEXEC"); +_Static_assert (((SOCK_MAX - 1) | SOCK_TYPE_MASK) == SOCK_TYPE_MASK, + "SOCK_TYPE_MASK must contain SOCK_MAX - 1"); +_Static_assert ((SOCK_CLOEXEC & SOCK_TYPE_MASK) == 0, + "SOCK_TYPE_MASK must not contain SOCK_CLOEXEC"); +_Static_assert ((SOCK_NONBLOCK & SOCK_TYPE_MASK) == 0, + "SOCK_TYPE_MASK must not contain SOCK_NONBLOCK"); + + +/* Convert from SOCK_* flags to O_* flags. */ +__extern_always_inline +int +sock_to_o_flags (int in) +{ + int out = 0; + + if (in & SOCK_NONBLOCK) + out |= O_NONBLOCK; + /* Others are passed through unfiltered. */ + out |= in & ~(SOCK_NONBLOCK); + + return out; +} + +/* Convert from O_* flags to SOCK_* flags. */ +__extern_always_inline +int +o_to_sock_flags (int in) +{ + int out = 0; + + if (in & O_NONBLOCK) + out |= SOCK_NONBLOCK; + /* Others are passed through unfiltered. */ + out |= in & ~(O_NONBLOCK); + + return out; +}