Beginnings of FreeBSD port!

This commit is contained in:
Hisham Muhammad 2014-11-27 16:27:34 -02:00
parent a75161f862
commit 8915b29395
8 changed files with 139 additions and 0 deletions

View File

@ -41,6 +41,14 @@ myhtopplatheaders = linux/Platform.h linux/IOPriorityPanel.h linux/IOPriority.h
linux/LinuxProcess.h linux/LinuxProcessList.h linux/LinuxCRT.h
endif
if HTOP_FREEBSD
myhtopplatsources = freebsd/Platform.c freebsd/FreeBSDProcessList.c \
freebsd/FreeBSDCRT.c
myhtopplatheaders = freebsd/Platform.h freebsd/FreeBSDProcessList.h \
freebsd/FreeBSDCRT.h
endif
if HTOP_UNSUPPORTED
myhtopplatsources = unsupported/Platform.c unsupported/UnsupportedProcessList.c \
unsupported/UnsupportedCRT.c

View File

@ -28,6 +28,9 @@ case "$target" in
*linux*)
my_htop_platform=linux
;;
*freebsd*)
my_htop_platform=freebsd
;;
*)
my_htop_platform=unsupported
;;
@ -183,6 +186,7 @@ fi
# We're done, let's go!
# ----------------------------------------------------------------------
AM_CONDITIONAL([HTOP_LINUX], [test "$my_htop_platform" = linux])
AM_CONDITIONAL([HTOP_FREEBSD], [test "$my_htop_platform" = freebsd])
AM_CONDITIONAL([HTOP_UNSUPPORTED], [test "$my_htop_platform" = unsupported])
AC_SUBST(my_htop_platform)
AC_CONFIG_FILES([Makefile htop.1])

21
freebsd/FreeBSDCRT.c Normal file
View File

@ -0,0 +1,21 @@
/*
htop - UnsupportedCRT.c
(C) 2014 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
#include "config.h"
#include "CRT.h"
#include <stdio.h>
#include <stdlib.h>
void CRT_handleSIGSEGV(int sgn) {
(void) sgn;
CRT_done();
fprintf(stderr, "\n\nhtop " VERSION " aborting.\n");
fprintf(stderr, "\nUnfortunately, you seem to be using an unsupported platform!");
fprintf(stderr, "\nPlease contact your platform package mantainer!\n\n");
abort();
}

15
freebsd/FreeBSDCRT.h Normal file
View File

@ -0,0 +1,15 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_UnsupportedCRT
#define HEADER_UnsupportedCRT
/*
htop - UnsupportedCRT.h
(C) 2014 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
void CRT_handleSIGSEGV(int sgn);
#endif

View File

@ -0,0 +1,39 @@
/*
htop - UnsupportedProcessList.c
(C) 2014 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
#include "ProcessList.h"
#include <stdlib.h>
#include <sys/sysctl.h>
/*{
}*/
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList) {
ProcessList* this = calloc(1, sizeof(ProcessList));
ProcessList_init(this, usersTable, pidWhiteList);
int cpus = 1;
size_t sizeof_cpus = sizeof(cpus);
int err = sysctlbyname("hw.ncpu", &cpus, &sizeof_cpus, NULL, 0);
if (err) cpus = 1;
this->cpuCount = MAX(cpus, 1);
this->cpus = realloc(this->cpus, cpus * sizeof(CPUData));
for (int i = 0; i < cpus; i++) {
this->cpus[i].totalTime = 1;
this->cpus[i].totalPeriod = 1;
}
return this;
}
void ProcessList_scan(ProcessList* this) {
(void) this;
// stub!
}

View File

@ -0,0 +1,18 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_FreeBSDProcessList
#define HEADER_FreeBSDProcessList
/*
htop - UnsupportedProcessList.h
(C) 2014 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList);
void ProcessList_scan(ProcessList* this);
#endif

17
freebsd/Platform.c Normal file
View File

@ -0,0 +1,17 @@
/*
htop - unsupported/Platform.c
(C) 2014 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
#include "Platform.h"
/*{
#include "Action.h"
}*/
void Platform_setBindings(Htop_Action* keys) {
(void) keys;
}

17
freebsd/Platform.h Normal file
View File

@ -0,0 +1,17 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_Platform
#define HEADER_Platform
/*
htop - unsupported/Platform.h
(C) 2014 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
#include "Action.h"
void Platform_setBindings(Htop_Action* keys);
#endif