<commit_before>/**
 * @file
 * @brief
 * @version 0.2
 * @date Jun 21, 2017
 * @author <NAME>
 * @author <NAME> <<EMAIL>>
 */

#include <assert.h>
#include <fcntl.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <time.h>
#include <unistd.h>

#include <drivers/video/fb.h>

#include <GL/osmesa.h>
#include <GL/glu.h>
#include <GL/gl.h>


extern void cxx_app_startup(void);
extern void text_layout_init(struct fb_info *fbi, void *base);
extern void put_char(int x, int y, char ch);
extern void put_string(int x, int y, char *str);

static int Width;
static int Height;
static struct fb_info *mesa_fbi;
static void *hw_base = 0;
static void *sw_base = 0;

static int animated_scene = 1;

void init_buffers(void) {
	long int screensize = 0;

	mesa_fbi = fb_lookup(0);

	printf("%dx%d, %dbpp\n", mesa_fbi->var.xres, mesa_fbi->var.yres,
			mesa_fbi->var.bits_per_pixel);

	Width = mesa_fbi->var.xres;
	Height = mesa_fbi->var.yres;

	screensize = Width * Height * mesa_fbi->var.bits_per_pixel / 8;

	/* Map the device to memory */
	hw_base = (uint8_t *) mmap_device_memory((void *) mesa_fbi->screen_base,
			screensize, PROT_READ | PROT_WRITE, MAP_SHARED,
			(uint64_t) ((uintptr_t) mesa_fbi->screen_base));


	if ((int) hw_base == -1) {
		perror("Error: failed to map framebuffer device to memory");
		exit(4);
	}

	printf("The framebuffer device was mapped to memory successfully.\n");

	sw_base = malloc(Width * Height * mesa_fbi->var.bits_per_pixel / 8);
	text_layout_init(mesa_fbi, sw_base);
}

static void swap_buffers() {
	static struct timespec time_prev;
	struct timespec time;
	static int fps = 0;<commit_msg>osdemo_fb: Get rid of mmap_device_memory()<commit_after>/**
 * @file
 * @brief
 * @version 0.2
 * @date Jun 21, 2017
 * @author <NAME>
 * @author <NAME> <<EMAIL>>
 */

#include <assert.h>
#include <fcntl.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <time.h>
#include <unistd.h>

#include <drivers/video/fb.h>

#include <GL/osmesa.h>
#include <GL/glu.h>
#include <GL/gl.h>


extern void cxx_app_startup(void);
extern void text_layout_init(struct fb_info *fbi, void *base);
extern void put_char(int x, int y, char ch);
extern void put_string(int x, int y, char *str);

static int Width;
static int Height;
static struct fb_info *mesa_fbi;
static void *hw_base = 0;
static void *sw_base = 0;

static int animated_scene = 1;

void init_buffers(void) {
	long int screensize = 0;

	mesa_fbi = fb_lookup(0);

	printf("%dx%d, %dbpp\n", mesa_fbi->var.xres, mesa_fbi->var.yres,
			mesa_fbi->var.bits_per_pixel);

	Width = mesa_fbi->var.xres;
	Height = mesa_fbi->var.yres;

	screensize = Width * Height * mesa_fbi->var.bits_per_pixel / 8;

	/* Map the device to memory */
	hw_base = 0 ? (uint8_t *) mmap_device_memory((void *) mesa_fbi->screen_base,
			screensize, PROT_READ | PROT_WRITE, MAP_SHARED,
			(uint64_t) ((uintptr_t) mesa_fbi->screen_base)) : (void *) mesa_fbi->screen_base;


	if ((int) hw_base == -1) {
		perror("Error: failed to map framebuffer device to memory");
		exit(4);
	}

	printf("The framebuffer device was mapped to memory successfully.\n");

	sw_base = malloc(Width * Height * mesa_fbi->var.bits_per_pixel / 8);
	text_layout_init(mesa_fbi, sw_base);
}

static void swap_buffers() {
	static struct timespec time_prev;
	struct timespec time;
	static int fps = 0;
{'fraction_non_alphanumeric': 0.1470758540822235, 'fraction_numerical': 0.012449334105385061, 'mean_word_length': 4.554662379421222, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 58, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3506834', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1385, 'n_words': 346}