After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 387200 - libgtop fails to build or work on FreeBSD
libgtop fails to build or work on FreeBSD
Status: RESOLVED FIXED
Product: libgtop
Classification: Core
Component: bsd
2.14.x
Other FreeBSD
: Normal normal
: ---
Assigned To: libgtop maintainers
libgtop maintainers
Depends on:
Blocks:
 
 
Reported: 2006-12-18 16:41 UTC by Roy Marples
Modified: 2007-02-05 21:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix generic read/write (1.42 KB, patch)
2006-12-18 16:43 UTC, Roy Marples
none Details | Review
FreeBSD patch (14.73 KB, patch)
2006-12-18 16:45 UTC, Roy Marples
none Details | Review
FreeBSD patch (14.60 KB, patch)
2007-01-18 13:58 UTC, Roy Marples
none Details | Review
FreeBSD patch (16.28 KB, patch)
2007-01-29 17:02 UTC, Roy Marples
none Details | Review
FreeBSD patch (12.47 KB, patch)
2007-01-30 10:51 UTC, Roy Marples
none Details | Review
FreeBSD patch (12.51 KB, patch)
2007-01-30 13:37 UTC, Roy Marples
committed Details | Review

Description Roy Marples 2006-12-18 16:41:41 UTC
Downstream bug
http://bugs.gentoo.org/show_bug.cgi?id=158030

(2.15 also fails, but we don't have that in portage yet)

Patches to follow
Comment 1 Roy Marples 2006-12-18 16:43:00 UTC
Created attachment 78574 [details] [review]
Fix generic read/write
Comment 2 Roy Marples 2006-12-18 16:45:40 UTC
Created attachment 78575 [details] [review]
FreeBSD patch

Make libgtop work with Gentoo/FreeBSD-6

This patch is made up from patches taken from the FreeBSD ports tree - I couldn't find any reference to this upstream so I'm basically submitting their patches. I cannot claim to understand it completely, but it does enable System Monitor to report everything correctly.
Comment 3 Roy Marples 2007-01-18 13:58:03 UTC
Created attachment 80596 [details] [review]
FreeBSD patch

For 2.14.6
Comment 4 Benoît Dejean 2007-01-18 19:29:13 UTC
Sorry i'm late. Let me first hand your patch to Petr Salinger so he can check if it's OK with kfreebsd.
Comment 5 Petr Salinger 2007-01-19 12:28:20 UTC
(In reply to comment #4)
> Sorry i'm late. Let me first hand your patch to Petr Salinger so he can check
> if it's OK with kfreebsd.

At first look, it will break GNU/kFreeBSD, moreover it is wrong:

+       int result;
+       struct statfs sfs;
+#if __FreeBSD_version >= 600000
+       struct devstat *ds;
+       void *sc;
+       struct timespec ts;
+       struct gprovider *gp;
+       struct gident *gid;
+       struct gmesh gmp;
+       double etime;
+       uint64_t ld[2];
 #endif
+ 
+       if (result == -1) {
+               glibtop_warn_io_r (server, "statfs");
+               return;


So the "result" is autovariable,  it contains garbage from stack,
but is is compared to "-1".

In general, I would be nice to have some common header included from
all (k)freebsd specific sources, which would contain

#include <sys/param.h>
#if !defined(__FreeBSD_kernel_version) && defined(__FreeBSD_version)
#define __FreeBSD_kernel_version __FreeBSD_version
#endif

#if !defined(__FreeBSD_kernel__) && defined(__FreeBSD__)
#define __FreeBSD_kernel__ __FreeBSD__
#endif

And all tests against kernel version would use only __FreeBSD_kernel_version/
__FreeBSD_kernel__.

The macro __FreeBSD__ signals FreeBSD kernel and FreeBSD libc,
the macro __FreeBSD_kernel__ signals FreeBSD kernel.

So i.e. access for <machine/endian.h> should be guarded by  __FreeBSD__,
but in most cases in libgtop it should be guarded by __FreeBSD_kernel__/__FreeBSD_kernel_version.

Petr
Comment 6 Roy Marples 2007-01-29 17:02:12 UTC
Created attachment 81448 [details] [review]
FreeBSD patch

OK, I've taken the above comments into account. This new patch should address them.

NOTE - Existing #ifdefs for any fbsd stuff have not been touched.
Comment 7 Petr Salinger 2007-01-29 19:49:16 UTC
The last version of patch does not break GNU/kFreeBSD,
but due to dropping POSIX <sys/statvfs.h> it still might break
other OS which use freebsd sysdeps (netbsd*|openbsd*|bsdi*).

The suggestion for common header have been meant mainly for future, 
not for 2.14.x series. Would be possible for 2.15 or 2.17 series rename sysdeps/freebsd/ into sysdeps/bsd/ and apply the idea of common header included from all bsd specific sources and change in all tests
__FreeBSD__ ->  __FreeBSD_kernel__
__FreeBSD_version -> FreeBSD_kernel_version

I would after that test on GNU/kFreeBSD and mark places,
where really macros __FreeBSD__ and __FreeBSD_version belongs.

Petr
Comment 8 Roy Marples 2007-01-29 20:57:44 UTC
(In reply to comment #7)
> The last version of patch does not break GNU/kFreeBSD,
> but due to dropping POSIX <sys/statvfs.h> it still might break
> other OS which use freebsd sysdeps (netbsd*|openbsd*|bsdi*).

I checked NetBSD man pages and they no longer define statfs.
As I said earlier, the patch contents are from FreeBSD ports and I haven't had time to fully understand them yet.

I'll see if I can make it work using statvfs - shouldn't be hard though.

> The suggestion for common header have been meant mainly for future, 
> not for 2.14.x series.

Fair enough. I'm just interested in the here and now though. So will that code work on kFreeBSD using libgeom? Should I be testing __FreeBSD_version and FreeBSD_kernel_version at the same time?

Thanks

Roy
Comment 9 Petr Salinger 2007-01-29 21:21:43 UTC
> I'm just interested in the here and now though. So will that 
> code work on kFreeBSD using libgeom? Should I be testing __FreeBSD_version 
> and FreeBSD_kernel_version at the same time?

No. We have libgeom, but we do not have (yet ?) libdevstat.

Petr


Comment 10 Roy Marples 2007-01-30 10:51:09 UTC
Created attachment 81508 [details] [review]
FreeBSD patch

Lets make things very simple then.
It seems the error is purely because FreeBSD statvfs does not define the required fields in the structure. So simply undefing the fact that it has them enables it to work. This should also enable accurate reporting on kFreeBSD - but I cannot test this.
Comment 11 Petr Salinger 2007-01-30 12:24:10 UTC
Looks good for GNU/kFreeBSD. Only in sysdeps/freebsd/proctime.c chunk
"#if (__FreeBSD_version >= 600000) || (__FreeBSD_kernel_version >= 600000)"
could be used instead of "#if __FreeBSD_version >= 600000".

Petr

Comment 12 Roy Marples 2007-01-30 13:37:02 UTC
Created attachment 81514 [details] [review]
FreeBSD patch

Good catch.

Hopefully this is now final and can be merged :)
Comment 13 Benoît Dejean 2007-01-31 21:27:53 UTC
Thank you both. Is the bug about read/write still relevant ?
Comment 14 Roy Marples 2007-02-05 17:19:09 UTC
(In reply to comment #13)
> Thank you both. Is the bug about read/write still relevant ?

Not any more from my testing.

If it rears it's ugly head again, I'll open a new bug if needed :)
Comment 15 Benoît Dejean 2007-02-05 21:51:50 UTC
Closing then.
Thanks again.