From 517c9e8a6df2810ddb123a8f475e0dc48cb04b75 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 15 Feb 2007 23:50:45 +0000 Subject: [PATCH] Patched fbcon to compile on newer Linux kernels that don't #define PAGE_SIZE, since a memory page's size may vary on various architectures and kernel configurations. Will use getpagesize() if it exists, the PAGE_SIZE #define from older kernels if that doesn't, and #error out if that's not there either...but it's probably 4096 in that case. We may revisit this. Fixes Bugzilla #392. --- configure.in | 1 + include/SDL_config.h.in | 1 + src/video/fbcon/SDL_fbvideo.c | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index aefd09ad7..c2a2ff325 100644 --- a/configure.in +++ b/configure.in @@ -1125,6 +1125,7 @@ AC_HELP_STRING([--enable-video-fbcon], [use framebuffer console video driver [[d ]) AC_MSG_RESULT($video_fbcon) if test x$video_fbcon = xyes; then + AC_CHECK_FUNCS(getpagesize) AC_DEFINE(SDL_VIDEO_DRIVER_FBCON) SOURCES="$SOURCES $srcdir/src/video/fbcon/*.c" have_video=yes diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 89252e46d..afd6eb73f 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -130,6 +130,7 @@ #undef HAVE_NANOSLEEP #undef HAVE_CLOCK_GETTIME #undef HAVE_DLVSYM +#undef HAVE_GETPAGESIZE #else /* We may need some replacement for stdarg.h here */ diff --git a/src/video/fbcon/SDL_fbvideo.c b/src/video/fbcon/SDL_fbvideo.c index 2d97bcbeb..baf6aeb24 100644 --- a/src/video/fbcon/SDL_fbvideo.c +++ b/src/video/fbcon/SDL_fbvideo.c @@ -149,6 +149,19 @@ static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo, struct fb_var_screeninfo *vinfo); static void FB_RestorePalette(_THIS); +static int SDL_getpagesize(void) +{ +#ifdef HAVE_GETPAGESIZE + return getpagesize(); +#elif defined(PAGE_SIZE) + return PAGE_SIZE; +#else +#error Can not determine system page size. + return 4096; /* this is what it USED to be in Linux... */ +#endif +} + + /* Small wrapper for mmap() so we can play nicely with no-mmu hosts * (non-mmu hosts disallow the MAP_SHARED flag) */ @@ -466,6 +479,7 @@ static void FB_SortModes(_THIS) static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat) { + const int pagesize = SDL_getpagesize(); struct fb_fix_screeninfo finfo; struct fb_var_screeninfo vinfo; int i, j; @@ -547,7 +561,7 @@ static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat) /* Memory map the device, compensating for buggy PPC mmap() */ mapped_offset = (((long)finfo.smem_start) - - (((long)finfo.smem_start)&~(PAGE_SIZE-1))); + (((long)finfo.smem_start)&~(pagesize-1))); mapped_memlen = finfo.smem_len+mapped_offset; mapped_mem = do_mmap(NULL, mapped_memlen, PROT_READ|PROT_WRITE, MAP_SHARED, console_fd, 0);