Commit 93852599 authored by Damjan Jovanovic's avatar Damjan Jovanovic Committed by Alexandre Julliard

server: Implement vm counters on FreeBSD.

parent f3478b4e
...@@ -49,6 +49,6 @@ MANPAGES = \ ...@@ -49,6 +49,6 @@ MANPAGES = \
wineserver.fr.UTF-8.man.in \ wineserver.fr.UTF-8.man.in \
wineserver.man.in wineserver.man.in
EXTRALIBS = $(LDEXECFLAGS) $(RT_LIBS) $(INOTIFY_LIBS) EXTRALIBS = $(LDEXECFLAGS) $(RT_LIBS) $(INOTIFY_LIBS) $(PROCSTAT_LIBS)
unicode_EXTRADEFS = -DNLSDIR="\"${nlsdir}\"" -DBIN_TO_NLSDIR=\"`${MAKEDEP} -R ${bindir} ${nlsdir}`\" unicode_EXTRADEFS = -DNLSDIR="\"${nlsdir}\"" -DBIN_TO_NLSDIR=\"`${MAKEDEP} -R ${bindir} ${nlsdir}`\"
...@@ -36,6 +36,23 @@ ...@@ -36,6 +36,23 @@
#endif #endif
#include <unistd.h> #include <unistd.h>
#include <poll.h> #include <poll.h>
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
#ifdef HAVE_SYS_QUEUE_H
# include <sys/queue.h>
#endif
#ifdef HAVE_SYS_SYSCTL_H
# include <sys/sysctl.h>
#endif
#ifdef HAVE_SYS_USER_H
# define thread __unix_thread
# include <sys/user.h>
# undef thread
#endif
#ifdef HAVE_LIBPROCSTAT
# include <libprocstat.h>
#endif
#include "ntstatus.h" #include "ntstatus.h"
#define WIN32_NO_STATUS #define WIN32_NO_STATUS
...@@ -1550,9 +1567,9 @@ DECL_HANDLER(get_process_vm_counters) ...@@ -1550,9 +1567,9 @@ DECL_HANDLER(get_process_vm_counters)
struct process *process = get_process_from_handle( req->handle, PROCESS_QUERY_LIMITED_INFORMATION ); struct process *process = get_process_from_handle( req->handle, PROCESS_QUERY_LIMITED_INFORMATION );
if (!process) return; if (!process) return;
#ifdef linux
if (process->unix_pid != -1) if (process->unix_pid != -1)
{ {
#ifdef linux
FILE *f; FILE *f;
char proc_path[32], line[256]; char proc_path[32], line[256];
unsigned long value; unsigned long value;
...@@ -1579,9 +1596,28 @@ DECL_HANDLER(get_process_vm_counters) ...@@ -1579,9 +1596,28 @@ DECL_HANDLER(get_process_vm_counters)
fclose( f ); fclose( f );
} }
else set_error( STATUS_ACCESS_DENIED ); else set_error( STATUS_ACCESS_DENIED );
#elif defined(HAVE_LIBPROCSTAT)
struct procstat *procstat;
unsigned int count;
if ((procstat = procstat_open_sysctl()))
{
struct kinfo_proc *kp = procstat_getprocs( procstat, KERN_PROC_PID, process->unix_pid, &count );
if (kp)
{
reply->virtual_size = kp->ki_size;
reply->peak_virtual_size = reply->virtual_size;
reply->working_set_size = kp->ki_rssize << PAGE_SHIFT;
reply->peak_working_set_size = kp->ki_rusage.ru_maxrss * 1024;
procstat_freeprocs( procstat, kp );
}
else set_error( STATUS_ACCESS_DENIED );
procstat_close( procstat );
} }
else set_error( STATUS_ACCESS_DENIED ); else set_error( STATUS_ACCESS_DENIED );
#endif #endif
}
else set_error( STATUS_ACCESS_DENIED );
release_object( process ); release_object( process );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment