1 | /****************************************************************************** |
---|
2 | * Fast DXT - a realtime DXT compression tool |
---|
3 | * |
---|
4 | * Author : Luc Renambot |
---|
5 | * |
---|
6 | * Copyright (C) 2007 Electronic Visualization Laboratory, |
---|
7 | * University of Illinois at Chicago |
---|
8 | * |
---|
9 | * All rights reserved. |
---|
10 | * |
---|
11 | * Redistribution and use in source and binary forms, with or without |
---|
12 | * modification, are permitted provided that the following conditions are met: |
---|
13 | * |
---|
14 | * * Redistributions of source code must retain the above copyright |
---|
15 | * notice, this list of conditions and the following disclaimer. |
---|
16 | * * Redistributions in binary form must reproduce the above |
---|
17 | * copyright notice, this list of conditions and the following disclaimer |
---|
18 | * in the documentation and/or other materials provided with the distribution. |
---|
19 | * * Neither the name of the University of Illinois at Chicago nor |
---|
20 | * the names of its contributors may be used to endorse or promote |
---|
21 | * products derived from this software without specific prior written permission. |
---|
22 | * |
---|
23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
26 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
---|
27 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
---|
28 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
29 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
---|
30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
---|
31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
---|
32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
---|
33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
34 | * |
---|
35 | * Direct questions, comments etc about SAGE to http://www.evl.uic.edu/cavern/forum/ |
---|
36 | * |
---|
37 | *****************************************************************************/ |
---|
38 | |
---|
39 | |
---|
40 | #include <stdio.h> |
---|
41 | #include <stdlib.h> |
---|
42 | #include <string.h> |
---|
43 | |
---|
44 | #include <vector> |
---|
45 | #include <string> |
---|
46 | #include <sys/stat.h> |
---|
47 | #include <sys/types.h> |
---|
48 | |
---|
49 | #if !defined(WIN32) |
---|
50 | #include <unistd.h> |
---|
51 | #include <sys/time.h> |
---|
52 | #else |
---|
53 | #define WIN32_LEAN_AND_MEAN |
---|
54 | #include <windows.h> |
---|
55 | #pragma warning(disable:4786) // symbol size limitation ... STL |
---|
56 | #endif |
---|
57 | |
---|
58 | |
---|
59 | #include <sys/stat.h> |
---|
60 | #include <sys/types.h> |
---|
61 | #include <fcntl.h> |
---|
62 | |
---|
63 | #include <stdarg.h> |
---|
64 | //#include <values.h> |
---|
65 | |
---|
66 | |
---|
67 | void aInitialize(); |
---|
68 | |
---|
69 | double aTime(); |
---|
70 | |
---|
71 | void aLog(char* format,...); |
---|
72 | void aError(char* format,...); |
---|
73 | |
---|
74 | void* aAlloc(size_t const n); |
---|
75 | void aFree(void* const p); |
---|
76 | |
---|
77 | #if defined(WIN32) |
---|
78 | float drand48(void); |
---|
79 | #endif |
---|
80 | |
---|
81 | #if defined(__APPLE__) |
---|
82 | #define memalign(x,y) malloc((y)) |
---|
83 | #else |
---|
84 | #include <malloc.h> |
---|
85 | #endif |
---|
86 | |
---|
87 | |
---|
88 | #if defined(WIN32) |
---|
89 | void *aligned_malloc(size_t size, size_t align_size); |
---|
90 | #define memalign(x,y) aligned_malloc(y, x) |
---|
91 | void aligned_free(void *ptr); |
---|
92 | #define memfree(x) aligned_free(x) |
---|
93 | #else |
---|
94 | #define memfree(x) free(x) |
---|
95 | #endif |
---|
96 | |
---|
97 | |
---|
98 | // From NVIDIA Toolkit |
---|
99 | |
---|
100 | #ifndef DATA_PATH_H |
---|
101 | #define DATA_PATH_H |
---|
102 | |
---|
103 | class data_path |
---|
104 | { |
---|
105 | public: |
---|
106 | std::string file_path; |
---|
107 | std::string path_name; |
---|
108 | std::vector<std::string> path; |
---|
109 | |
---|
110 | std::string get_path(std::string filename); |
---|
111 | std::string get_file(std::string filename); |
---|
112 | |
---|
113 | FILE *fopen(std::string filename, const char * mode = "rb"); |
---|
114 | |
---|
115 | #ifdef WIN32 |
---|
116 | int fstat(std::string filename, struct _stat * stat); |
---|
117 | #else |
---|
118 | int fstat(std::string filename, struct stat * stat); |
---|
119 | #endif |
---|
120 | }; |
---|
121 | |
---|
122 | #endif |
---|