Package: bogl-bterm
Version: 0.1.18-1.2
Tags: patch
bogl.c currently uses PAGE_MASK from <asm/page.h>. Recent kernel
versions on IA-64 define PAGE_MASK only #ifdef __KERNEL__, and even then
it represents the kernel internal page size, which depends on kernel
config, not the ABI page size.
The attached patch replaces the PAGE_MASK use by portable
sysconf(_SC_PAGE_SIZE). This fixes the build on IA-64, but I haven't
tested the resulting IA-64 binary.
Thanks,
Mirek
--- bogl-0.1.18/bogl.c.page_size 2006-10-17 02:41:01.000000000 +0200
+++ bogl-0.1.18/bogl.c 2006-10-17 02:47:20.000000000 +0200
@@ -40,10 +40,6 @@
#include <termios.h>
#include <unistd.h>
-/* Yes, I know, we shouldn't be including headers from the kernel. But
- XFree86 also uses this one (to get PAGE_MASK) so it's probably safe. */
-#include <asm/page.h>
-
#include "bogl.h"
#include "boglP.h"
#if BOGL_VGA16_FB
@@ -115,6 +111,7 @@
bogl_init (void)
{
unsigned long bogl_frame_offset, bogl_frame_len;
+ long page_size;
struct fb_var_screeninfo fb_var;
struct vt_stat vts;
@@ -178,9 +175,14 @@
if (!init_fb())
return 0;
- bogl_frame_offset = fb_fix.smem_start & ~PAGE_MASK;
- bogl_frame_len = ((bogl_frame_offset + fb_fix.smem_len + ~PAGE_MASK)
- & PAGE_MASK);
+ errno = 0;
+ page_size = sysconf(_SC_PAGE_SIZE);
+ if (page_size == -1 && errno != 0)
+ return bogl_fail ("can't get PAGE_SIZE: %s", strerror (errno));
+
+ bogl_frame_offset = fb_fix.smem_start & (page_size - 1);
+ bogl_frame_len = ((bogl_frame_offset + fb_fix.smem_len + page_size - 1)
+ & ~(page_size - 1));
bogl_frame_mapped
= mmap (NULL, bogl_frame_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0);