From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 4A6733857C74; Tue, 14 Sep 2021 15:05:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A6733857C74 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: move get_obj_handle_count() to miscfuncs.cc X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: 9cfbb5aa82fc9ff49b1468bfad9d446eecb207c0 X-Git-Newrev: e9d4cb765fbf06485eda62e5b4ae83ad2710e226 Message-Id: <20210914150549.4A6733857C74@sourceware.org> Date: Tue, 14 Sep 2021 15:05:49 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Sep 2021 15:05:49 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e9d4cb765fbf06485eda62e5b4ae83ad2710e226 commit e9d4cb765fbf06485eda62e5b4ae83ad2710e226 Author: Corinna Vinschen Date: Fri Sep 3 10:15:57 2021 +0200 Cygwin: move get_obj_handle_count() to miscfuncs.cc get_obj_handle_count() is used in flock only so far, but pipe handling might have a usage, too, soon. Given that this function might be generally useful and isn't restricted to flock usage, move it to miscfuncs.cc and make it non-static. Add a prototype in miscfuncs.h. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/flock.cc | 16 ---------------- winsup/cygwin/miscfuncs.cc | 16 ++++++++++++++++ winsup/cygwin/miscfuncs.h | 3 +++ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/winsup/cygwin/flock.cc b/winsup/cygwin/flock.cc index bd7a16d91..2f12fc07e 100644 --- a/winsup/cygwin/flock.cc +++ b/winsup/cygwin/flock.cc @@ -216,22 +216,6 @@ allow_others_to_sync () done = true; } -/* Get the handle count of an object. */ -static ULONG -get_obj_handle_count (HANDLE h) -{ - OBJECT_BASIC_INFORMATION obi; - NTSTATUS status; - ULONG hdl_cnt = 0; - - status = NtQueryObject (h, ObjectBasicInformation, &obi, sizeof obi, NULL); - if (!NT_SUCCESS (status)) - debug_printf ("NtQueryObject: %y", status); - else - hdl_cnt = obi.HandleCount; - return hdl_cnt; -} - /* Helper struct to construct a local OBJECT_ATTRIBUTES on the stack. */ struct lockfattr_t { diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index 024ad70ba..adf9a3d0f 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -18,6 +18,22 @@ details. */ #include "tls_pbuf.h" #include "mmap_alloc.h" +/* Get handle count of an object. */ +ULONG +get_obj_handle_count (HANDLE h) +{ + OBJECT_BASIC_INFORMATION obi; + NTSTATUS status; + ULONG hdl_cnt = 0; + + status = NtQueryObject (h, ObjectBasicInformation, &obi, sizeof obi, NULL); + if (!NT_SUCCESS (status)) + debug_printf ("NtQueryObject: %y", status); + else + hdl_cnt = obi.HandleCount; + return hdl_cnt; +} + int __reg2 check_invalid_virtual_addr (const void *s, unsigned sz) { diff --git a/winsup/cygwin/miscfuncs.h b/winsup/cygwin/miscfuncs.h index 1ff7ee0d3..47cef6f20 100644 --- a/winsup/cygwin/miscfuncs.h +++ b/winsup/cygwin/miscfuncs.h @@ -98,6 +98,9 @@ transform_chars (PUNICODE_STRING upath, USHORT start_idx) PWCHAR transform_chars_af_unix (PWCHAR, const char *, __socklen_t); +/* Get handle count of an object. */ +ULONG get_obj_handle_count (HANDLE h); + /* Memory checking */ int __reg2 check_invalid_virtual_addr (const void *s, unsigned sz);