| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <fcntl.h> | 5 #include <fcntl.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <sys/mman.h> | 8 #include <sys/mman.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 | 10 |
| 11 #include "utils.h" | |
| 12 | |
| 13 #include "base/file_path.h" | |
| 14 #include "base/logging.h" | 11 #include "base/logging.h" |
| 15 #include "main.h" | 12 #include "main.h" |
| 13 #include "utils.h" |
| 16 | 14 |
| 17 FilePath *g_base_path = new FilePath(); | 15 FilePath *g_base_path = new FilePath(); |
| 18 | 16 |
| 19 // Sets the base path for MmapFile to `dirname($argv0)`/$relative. | 17 // Sets the base path for MmapFile to `dirname($argv0)`/$relative. |
| 20 void SetBasePathFromArgv0(const char* argv0, const char* relative) { | 18 void SetBasePathFromArgv0(const char* argv0, const char* relative) { |
| 21 if (g_base_path) { | 19 if (g_base_path) { |
| 22 delete g_base_path; | 20 delete g_base_path; |
| 23 } | 21 } |
| 24 FilePath argv0_path = FilePath(argv0).DirName(); | 22 FilePath argv0_path = FilePath(argv0).DirName(); |
| 25 FilePath base_path = relative ? argv0_path.Append(relative) : argv0_path; | 23 FilePath base_path = relative ? argv0_path.Append(relative) : argv0_path; |
| 26 g_base_path = new FilePath(base_path); | 24 g_base_path = new FilePath(base_path); |
| 27 } | 25 } |
| 28 | 26 |
| 27 const FilePath& GetBasePath() { |
| 28 return *g_base_path; |
| 29 } |
| 30 |
| 29 void *MmapFile(const char* name, size_t* length) { | 31 void *MmapFile(const char* name, size_t* length) { |
| 30 FilePath filename = g_base_path->Append(name); | 32 FilePath filename = g_base_path->Append(name); |
| 31 int fd = open(filename.value().c_str(), O_RDONLY); | 33 int fd = open(filename.value().c_str(), O_RDONLY); |
| 32 if (fd == -1) | 34 if (fd == -1) |
| 33 return NULL; | 35 return NULL; |
| 34 | 36 |
| 35 struct stat sb; | 37 struct stat sb; |
| 36 CHECK(fstat(fd, &sb) != -1); | 38 CHECK(fstat(fd, &sb) != -1); |
| 37 | 39 |
| 38 char *mmap_ptr = static_cast<char *>( | 40 char *mmap_ptr = static_cast<char *>( |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 print_info_log(program); | 197 print_info_log(program); |
| 196 glUseProgram(program); | 198 glUseProgram(program); |
| 197 | 199 |
| 198 glDeleteShader(vertex_shader); | 200 glDeleteShader(vertex_shader); |
| 199 glDeleteShader(fragment_shader); | 201 glDeleteShader(fragment_shader); |
| 200 | 202 |
| 201 return program; | 203 return program; |
| 202 } | 204 } |
| 203 | 205 |
| 204 } // namespace glbench | 206 } // namespace glbench |
| OLD | NEW |