formatting, add freebsd support

This commit is contained in:
bch 2018-12-26 18:46:04 +00:00
parent 06227deb08
commit 3b3d39c18c
3 changed files with 139 additions and 121 deletions

View File

@ -1,8 +1,23 @@
OS = FreeBSD
PROG= xmem PROG= xmem
VERSION= 1.26 VERSION= 1.26
LDFLAGS+= -L/usr/X11R6/lib -lX11 -lXt -lXaw -lXmu FreeBSD_lflag= -lkvm
CFLAGS+= -Wall -I/usr/X11R6/include/ LDFLAGS+= -L/usr/X11R6/lib -L/usr/local/lib/ -lX11 -lXt -lXaw -lXmu
OBJECTS= xmem.o get_mem.o MemStripChart.o LDFLAGS+= $($(OS)_lflag)
CFLAGS+= -Wall -I/usr/X11R6/include/ -I/usr/local/include/
OBJECTS= xmem.o MemStripChart.o
FreeBSD_stub = get_mem_fbsd.o
OpenBSD_stub = get_mem.o
OBJECTS += $($(OS)_stub)
all: xmem
xmem.full:
echo full
xmem.debug:
echo full
xmem: $(OBJECTS) xmem: $(OBJECTS)
$(CC) -o xmem $(OBJECTS) $(LDFLAGS) $(CC) -o xmem $(OBJECTS) $(LDFLAGS)
@ -33,6 +48,5 @@ install:
install -c -o root -g bin -m 644 xmem.bit ${PREFIX}/share/${PROG}/xmem.bit install -c -o root -g bin -m 644 xmem.bit ${PREFIX}/share/${PROG}/xmem.bit
install -c -o root -g bin -m 644 copyright ${PREFIX}/share/${PROG}/copyright install -c -o root -g bin -m 644 copyright ${PREFIX}/share/${PROG}/copyright
all: xmem
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@ -1,6 +1,7 @@
/* $Id: get_mem.c,v 1.4 2017/02/26 16:03:48 bch Exp $ /* $Id: get_mem.c,v 1.5 2018/12/26 18:46:04 bch Exp $
*
* Adapted: get memory usage on OpenBSD * Adapted: get memory usage on OpenBSD
* Author: Christian Barthel <bch@vcs.onfire.org> * Author: Christian Barthel <bch@online.de>
* *
* get memory usage, from get_load.c derived * get memory usage, from get_load.c derived
* *
@ -9,6 +10,7 @@
* Modified for more recent kernels Helmut Geyer Oct. 1996 * Modified for more recent kernels Helmut Geyer Oct. 1996
*/ */
#include <sys/param.h> /* DEV_BSIZE MAXCOMLEN PZERO */ #include <sys/param.h> /* DEV_BSIZE MAXCOMLEN PZERO */
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <sys/swap.h> #include <sys/swap.h>

4
xmem.c
View File

@ -1,7 +1,7 @@
/* /*
* xmem - display memory/swap usage utility for X * xmem - display memory/swap usage utility for X
* *
* Updated by Christian Barthel <bch@onfire.org> * Updated by Christian Barthel <bch@online.de>
* *
* Copyright 1989 Massachusetts Institute of Technology * Copyright 1989 Massachusetts Institute of Technology
* *
@ -204,8 +204,10 @@ int main(int argc, char **argv)
(void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel), (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel),
&wm_delete_window, 1); &wm_delete_window, 1);
#if __OpenBSD__
if (pledge("ps vminfo stdio", NULL) == -1) if (pledge("ps vminfo stdio", NULL) == -1)
errx(1, "pledge failed: %s", strerror(errno)); errx(1, "pledge failed: %s", strerror(errno));
#endif
XtAppMainLoop(app_con); XtAppMainLoop(app_con);
return 0; return 0;