1 /* 2 (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) 3 (c) Copyright 2000-2004 Convergence (integrated media) GmbH 4 5 All rights reserved. 6 7 Written by Denis Oliver Kropp <dok@directfb.org>, 8 Andreas Hundt <andi@fischlustig.de>, 9 Sven Neumann <neo@directfb.org>, 10 Ville Syrjälä <syrjala@sci.fi> and 11 Claudio Ciccani <klan@users.sf.net>. 12 13 This library is free software; you can redistribute it and/or 14 modify it under the terms of the GNU Lesser General Public 15 License as published by the Free Software Foundation; either 16 version 2 of the License, or (at your option) any later version. 17 18 This library is distributed in the hope that it will be useful, 19 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 Lesser General Public License for more details. 22 23 You should have received a copy of the GNU Lesser General Public 24 License along with this library; if not, write to the 25 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 26 Boston, MA 02111-1307, USA. 27 */ 28 29 #ifndef __DIRECT__TYPES_H__ 30 #define __DIRECT__TYPES_H__ 31 32 #include <direct/build.h> 33 34 /* 35 * Define the bool type by including stdbool.h (preferably)... 36 */ 37 #if DIRECT_BUILD_STDBOOL 38 # include <stdbool.h> 39 /* 40 * ...or defining it ourself, if not using C++ or another definition 41 */ 42 #elif !defined(__cplusplus) && !defined(__bool_true_false_are_defined) 43 # warning Fallback definition of bool using u8! Checking for 'flags & 0x100' or higher bits will be false :( 44 typedef u8 bool; 45 # ifndef false 46 # define false (0) 47 # endif 48 # ifndef true 49 # define true (!false) 50 # endif 51 #endif /* DIRECT_BUILD_STDBOOL */ 52 53 /* makes it possible to prevent definition of "direct" standard types */ 54 #ifndef __DIRECT__STDTYPES__ 55 #define __DIRECT__STDTYPES__ 56 #ifdef USE_KOS 57 58 #include <sys/types.h> 59 60 typedef uint8 u8; 61 typedef uint16 u16; 62 typedef uint32 u32; 63 typedef uint64 u64; 64 65 typedef sint8 s8; 66 typedef sint16 s16; 67 typedef sint32 s32; 68 typedef sint64 s64; 69 70 #else 71 72 #include <stdint.h> 73 74 typedef uint8_t u8; 75 typedef uint16_t u16; 76 typedef uint32_t u32; 77 typedef uint64_t u64; 78 79 typedef int8_t s8; 80 typedef int16_t s16; 81 typedef int32_t s32; 82 typedef int64_t s64; 83 84 #endif 85 #endif /* __DIRECT__STDTYPES__ */ 86 87 88 #include <sys/mman.h> 89 #include <sys/stat.h> 90 #include <dirent.h> 91 #include <fcntl.h> 92 #include <string.h> 93 #include <unistd.h> 94 95 96 #define D_UNUSED __attribute__((unused)) 97 #define direct_strcmp strcmp 98 99 100 typedef enum { 101 DR_OK = 0x00000000, /* No error occured. */ 102 DR_FAILURE, /* A general or unknown error occured. */ 103 DR_INIT, /* A general initialization error occured. */ 104 DR_BUG, /* Internal bug or inconsistency has been detected. */ 105 DR_DEAD, /* Interface has a zero reference counter (available in debug mode). */ 106 DR_UNSUPPORTED, /* The requested operation or an argument is (currently) not supported. */ 107 DR_UNIMPLEMENTED, /* The requested operation is not implemented, yet. */ 108 DR_ACCESSDENIED, /* Access to the resource is denied. */ 109 DR_INVAREA, /* An invalid area has been specified or detected. */ 110 DR_INVARG, /* An invalid argument has been specified. */ 111 DR_NOLOCALMEMORY, /* There's not enough local system memory. */ 112 DR_NOSHAREDMEMORY, /* There's not enough shared system memory. */ 113 DR_LOCKED, /* The resource is (already) locked. */ 114 DR_BUFFEREMPTY, /* The buffer is empty. */ 115 DR_FILENOTFOUND, /* The specified file has not been found. */ 116 DR_IO, /* A general I/O error occured. */ 117 DR_BUSY, /* The resource or device is busy. */ 118 DR_NOIMPL, /* No implementation for this interface or content type has been found. */ 119 DR_TIMEOUT, /* The operation timed out. */ 120 DR_THIZNULL, /* 'thiz' pointer is NULL. */ 121 DR_IDNOTFOUND, /* No resource has been found by the specified id. */ 122 DR_DESTROYED, /* The requested object has been destroyed. */ 123 DR_FUSION, /* Internal fusion error detected, most likely related to IPC resources. */ 124 DR_BUFFERTOOLARGE, /* Buffer is too large. */ 125 DR_INTERRUPTED, /* The operation has been interrupted. */ 126 DR_NOCONTEXT, /* No context available. */ 127 DR_TEMPUNAVAIL, /* Temporarily unavailable. */ 128 DR_LIMITEXCEEDED, /* Attempted to exceed limit, i.e. any kind of maximum size, count etc. */ 129 DR_NOSUCHMETHOD, /* Requested method is not known. */ 130 DR_NOSUCHINSTANCE, /* Requested instance is not known. */ 131 DR_ITEMNOTFOUND, /* No such item found. */ 132 DR_VERSIONMISMATCH, /* Some versions didn't match. */ 133 DR_EOF, /* Reached end of file. */ 134 DR_SUSPENDED, /* The requested object is suspended. */ 135 DR_INCOMPLETE, /* The operation has been executed, but not completely. */ 136 DR_NOCORE /* Core part not available. */ 137 } DirectResult; 138 139 /* 140 * Generate result code base for API 'A','B','C', e.g. 'D','F','B'. 141 */ 142 #define D_RESULT_TYPE_BASE( a,b,c ) ((((unsigned)(a)&0x7f) * 0x02000000) + \ 143 (((unsigned)(b)&0x7f) * 0x00040000) + \ 144 (((unsigned)(c)&0x7f) * 0x00000800)) 145 146 /* 147 * Generate result code maximum for API 'A','B','C', e.g. 'D','F','B'. 148 */ 149 #define D_RESULT_TYPE_MAX( a,b,c ) (D_RESULT_TYPE_BASE(a,b,c) + 0x7ff) 150 151 /* 152 * Check if given result code belongs to API 'A','B','C', e.g. 'D','F','B'. 153 */ 154 #define D_RESULT_TYPE_IS( code,a,b,c ) ((code) >= D_RESULT_TYPE_BASE(a,b,c) && (code) <= D_RESULT_TYPE_MAX(a,b,c)) 155 156 157 /* 158 * Return value of enumeration callbacks 159 */ 160 typedef enum { 161 DENUM_OK = 0x00000000, /* Proceed with enumeration */ 162 DENUM_CANCEL = 0x00000001 /* Cancel enumeration */ 163 } DirectEnumerationResult; 164 165 166 typedef u32 unichar; 167 168 typedef struct __D_DirectCleanupHandler DirectCleanupHandler; 169 typedef struct __D_DirectConfig DirectConfig; 170 typedef struct __D_DirectHash DirectHash; 171 typedef struct __D_DirectLink DirectLink; 172 typedef struct __D_DirectLog DirectLog; 173 typedef struct __D_DirectMap DirectMap; 174 typedef struct __D_DirectModuleDir DirectModuleDir; 175 typedef struct __D_DirectModuleEntry DirectModuleEntry; 176 typedef struct __D_DirectMutex DirectMutex; 177 typedef struct __D_DirectSerial DirectSerial; 178 typedef struct __D_DirectSignalHandler DirectSignalHandler; 179 typedef struct __D_DirectStream DirectStream; 180 typedef struct __D_DirectTraceBuffer DirectTraceBuffer; 181 typedef struct __D_DirectTree DirectTree; 182 typedef struct __D_DirectThread DirectThread; 183 typedef struct __D_DirectThreadInitHandler DirectThreadInitHandler; 184 185 #endif 186 187