comparison src/video/fbcon/SDL_fbvideo.c @ 2093:cdaeb26ed66a

Merged r2981:2982 from branches/SDL-1.2: fbcon getpagesize() compile fix.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 15 Feb 2007 23:57:07 +0000
parents c121d94672cb
children 87256df87837
comparison
equal deleted inserted replaced
2092:8e761d6af583 2093:cdaeb26ed66a
174 174
175 /* Internal palette functions */ 175 /* Internal palette functions */
176 static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo, 176 static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo,
177 struct fb_var_screeninfo *vinfo); 177 struct fb_var_screeninfo *vinfo);
178 static void FB_RestorePalette(_THIS); 178 static void FB_RestorePalette(_THIS);
179
180 static int SDL_getpagesize(void)
181 {
182 #ifdef HAVE_GETPAGESIZE
183 return getpagesize();
184 #elif defined(PAGE_SIZE)
185 return PAGE_SIZE;
186 #else
187 #error Can not determine system page size.
188 return 4096; /* this is what it USED to be in Linux... */
189 #endif
190 }
191
179 192
180 /* Small wrapper for mmap() so we can play nicely with no-mmu hosts 193 /* Small wrapper for mmap() so we can play nicely with no-mmu hosts
181 * (non-mmu hosts disallow the MAP_SHARED flag) */ 194 * (non-mmu hosts disallow the MAP_SHARED flag) */
182 195
183 static void * 196 static void *
506 } 519 }
507 520
508 static int 521 static int
509 FB_VideoInit(_THIS, SDL_PixelFormat * vformat) 522 FB_VideoInit(_THIS, SDL_PixelFormat * vformat)
510 { 523 {
524 const int pagesize = SDL_getpagesize();
511 struct fb_fix_screeninfo finfo; 525 struct fb_fix_screeninfo finfo;
512 struct fb_var_screeninfo vinfo; 526 struct fb_var_screeninfo vinfo;
513 int i, j; 527 int i, j;
514 int current_index; 528 int current_index;
515 unsigned int current_w; 529 unsigned int current_w;
587 } 601 }
588 } 602 }
589 603
590 /* Memory map the device, compensating for buggy PPC mmap() */ 604 /* Memory map the device, compensating for buggy PPC mmap() */
591 mapped_offset = (((long) finfo.smem_start) - 605 mapped_offset = (((long) finfo.smem_start) -
592 (((long) finfo.smem_start) & ~(PAGE_SIZE - 1))); 606 (((long) finfo.smem_start) & ~(pagesize - 1)));
593 mapped_memlen = finfo.smem_len + mapped_offset; 607 mapped_memlen = finfo.smem_len + mapped_offset;
594 mapped_mem = do_mmap(NULL, mapped_memlen, 608 mapped_mem = do_mmap(NULL, mapped_memlen,
595 PROT_READ | PROT_WRITE, MAP_SHARED, console_fd, 0); 609 PROT_READ | PROT_WRITE, MAP_SHARED, console_fd, 0);
596 if (mapped_mem == (char *) -1) { 610 if (mapped_mem == (char *) -1) {
597 SDL_SetError("Unable to memory map the video hardware"); 611 SDL_SetError("Unable to memory map the video hardware");