2ff0b512 |
1 | #ifndef __CORETYPES_H__ |
2 | #define __CORETYPES_H__ |
3 | |
4 | #include <stdint.h> |
5 | #include <stdio.h> |
6 | |
7 | #ifdef USE_LIBRETRO_VFS |
8 | #include <streams/file_stream_transforms.h> |
9 | #endif |
10 | |
11 | #define ARRAY_LENGTH(x) (sizeof(x)/sizeof(x[0])) |
12 | |
9e052883 |
13 | #if defined(__PS3__) || defined(__PSL1GHT__) |
14 | #undef UINT32 |
15 | #undef UINT16 |
16 | #undef UINT8 |
17 | #undef INT32 |
18 | #undef INT16 |
19 | #undef INT8 |
20 | #endif |
21 | |
2ff0b512 |
22 | typedef uint64_t UINT64; |
23 | typedef uint32_t UINT32; |
24 | typedef uint16_t UINT16; |
25 | typedef uint8_t UINT8; |
26 | |
27 | typedef int64_t INT64; |
28 | typedef int32_t INT32; |
29 | typedef int16_t INT16; |
30 | typedef int8_t INT8; |
31 | |
9e052883 |
32 | typedef struct chd_core_file { |
33 | /* |
34 | * arbitrary pointer to data the implementation uses to implement the below functions |
35 | */ |
36 | void *argp; |
2ff0b512 |
37 | |
9e052883 |
38 | /* |
39 | * return the size of a given file as a 64-bit unsigned integer. |
40 | * the position of the file pointer after calling this function is |
41 | * undefined because many implementations will seek to the end of the |
42 | * file and call ftell. |
43 | * |
44 | * on error, (UINT64)-1 is returned. |
45 | */ |
46 | UINT64(*fsize)(struct chd_core_file*); |
47 | |
48 | /* |
49 | * should match the behavior of fread, except the FILE* argument at the end |
50 | * will be replaced with a struct chd_core_file*. |
51 | */ |
52 | size_t(*fread)(void*,size_t,size_t,struct chd_core_file*); |
53 | |
54 | // closes the given file. |
55 | int (*fclose)(struct chd_core_file*); |
56 | |
57 | // fseek clone |
58 | int (*fseek)(struct chd_core_file*, INT64, int); |
59 | } core_file; |
60 | |
61 | static inline int core_fclose(core_file *fp) { |
62 | return fp->fclose(fp); |
63 | } |
64 | |
65 | static inline size_t core_fread(core_file *fp, void *ptr, size_t len) { |
66 | return fp->fread(ptr, 1, len, fp); |
67 | } |
68 | |
69 | static inline int core_fseek(core_file* fp, INT64 offset, int whence) { |
70 | return fp->fseek(fp, offset, whence); |
71 | } |
72 | |
73 | static inline UINT64 core_fsize(core_file *fp) |
2ff0b512 |
74 | { |
9e052883 |
75 | return fp->fsize(fp); |
2ff0b512 |
76 | } |
77 | |
78 | #endif |