public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: move get_obj_handle_count() to miscfuncs.cc
@ 2021-09-14 15:05 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2021-09-14 15:05 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e9d4cb765fbf06485eda62e5b4ae83ad2710e226
commit e9d4cb765fbf06485eda62e5b4ae83ad2710e226
Author: Corinna Vinschen <corinna@vinschen.de>
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 <corinna@vinschen.de>
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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-09-14 15:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 15:05 [newlib-cygwin] Cygwin: move get_obj_handle_count() to miscfuncs.cc Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).