diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2021-09-03 11:15:57 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2021-09-13 18:45:54 +0300 |
commit | e9d4cb765fbf06485eda62e5b4ae83ad2710e226 (patch) | |
tree | f11c4ccd32b285a90897176216712f080434733f /winsup/cygwin/miscfuncs.cc | |
parent | 9cfbb5aa82fc9ff49b1468bfad9d446eecb207c0 (diff) |
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>
Diffstat (limited to 'winsup/cygwin/miscfuncs.cc')
-rw-r--r-- | winsup/cygwin/miscfuncs.cc | 16 |
1 files changed, 16 insertions, 0 deletions
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) { |