Merged r2981:2982 from branches/SDL-1.2: fbcon getpagesize() compile fix.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 15 Feb 2007 23:57:07 +0000
changeset 2093cdaeb26ed66a
parent 2092 8e761d6af583
child 2094 7ba4a732e3d0
Merged r2981:2982 from branches/SDL-1.2: fbcon getpagesize() compile fix.
configure.in
include/SDL_config.h.in
src/video/fbcon/SDL_fbvideo.c
     1.1 --- a/configure.in	Thu Feb 15 11:14:24 2007 +0000
     1.2 +++ b/configure.in	Thu Feb 15 23:57:07 2007 +0000
     1.3 @@ -1117,6 +1117,7 @@
     1.4          ])
     1.5          AC_MSG_RESULT($video_fbcon)
     1.6          if test x$video_fbcon = xyes; then
     1.7 +            AC_CHECK_FUNCS(getpagesize)
     1.8              AC_DEFINE(SDL_VIDEO_DRIVER_FBCON)
     1.9              SOURCES="$SOURCES $srcdir/src/video/fbcon/*.c"
    1.10              have_video=yes
     2.1 --- a/include/SDL_config.h.in	Thu Feb 15 11:14:24 2007 +0000
     2.2 +++ b/include/SDL_config.h.in	Thu Feb 15 23:57:07 2007 +0000
     2.3 @@ -130,6 +130,7 @@
     2.4  #undef HAVE_NANOSLEEP
     2.5  #undef HAVE_CLOCK_GETTIME
     2.6  #undef HAVE_DLVSYM
     2.7 +#undef HAVE_GETPAGESIZE
     2.8  
     2.9  #else
    2.10  /* We may need some replacement for stdarg.h here */
     3.1 --- a/src/video/fbcon/SDL_fbvideo.c	Thu Feb 15 11:14:24 2007 +0000
     3.2 +++ b/src/video/fbcon/SDL_fbvideo.c	Thu Feb 15 23:57:07 2007 +0000
     3.3 @@ -177,6 +177,19 @@
     3.4                             struct fb_var_screeninfo *vinfo);
     3.5  static void FB_RestorePalette(_THIS);
     3.6  
     3.7 +static int SDL_getpagesize(void)
     3.8 +{
     3.9 +#ifdef HAVE_GETPAGESIZE
    3.10 +    return getpagesize();
    3.11 +#elif defined(PAGE_SIZE)
    3.12 +    return PAGE_SIZE;
    3.13 +#else
    3.14 +#error Can not determine system page size.
    3.15 +    return 4096;  /* this is what it USED to be in Linux... */
    3.16 +#endif
    3.17 +}
    3.18 +
    3.19 +
    3.20  /* Small wrapper for mmap() so we can play nicely with no-mmu hosts
    3.21   * (non-mmu hosts disallow the MAP_SHARED flag) */
    3.22  
    3.23 @@ -508,6 +521,7 @@
    3.24  static int
    3.25  FB_VideoInit(_THIS, SDL_PixelFormat * vformat)
    3.26  {
    3.27 +    const int pagesize = SDL_getpagesize();
    3.28      struct fb_fix_screeninfo finfo;
    3.29      struct fb_var_screeninfo vinfo;
    3.30      int i, j;
    3.31 @@ -589,7 +603,7 @@
    3.32  
    3.33      /* Memory map the device, compensating for buggy PPC mmap() */
    3.34      mapped_offset = (((long) finfo.smem_start) -
    3.35 -                     (((long) finfo.smem_start) & ~(PAGE_SIZE - 1)));
    3.36 +                     (((long) finfo.smem_start) & ~(pagesize - 1)));
    3.37      mapped_memlen = finfo.smem_len + mapped_offset;
    3.38      mapped_mem = do_mmap(NULL, mapped_memlen,
    3.39                           PROT_READ | PROT_WRITE, MAP_SHARED, console_fd, 0);