00001 //================================================================================================== 00002 // Copyright (C) 2010 Brian Tietz sdbtietz at yahoo dot com 00003 // 00004 // This program is free software; you can redistribute it and/or modify it under the terms of the 00005 // GNU General Public License as published by the Free Software Foundation, version 2.0 of the 00006 // License. 00007 // 00008 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 00009 // even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00010 // General Public License for more details. 00011 // 00012 // You should have received a copy of the GNU General Public License along with this program; if 00013 // not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00014 // 02110-1301, USA. 00015 // 00016 // For commercial software, the copyright holder (Brian Tietz, email sdbtietz at yahoo dot com) 00017 // reserves the right and is willing to waive the proprietary source code disclosure aspects of that 00018 // license as applied to the UT library in exchange for either substantial contributions to the 00019 // development of the UT library or other forms of compensation. Any such waiver must be 00020 // established in writing between the copyright holder and the commercial entity obtaining such a 00021 // waiver. 00022 //================================================================================================== 00023 00024 00025 #ifndef _UT_H_ 00026 #error "DO NOT INCLUDE THIS FILE - INCLUDE UT.h INSTEAD" 00027 #endif 00028 00029 #ifdef _UT_LINUX_TARGET_H_ 00030 #error "DO NOT INCLUDE THIS FILE - INCLUDE UT.h INSTEAD" 00031 #endif 00032 00033 #define _UT_LINUX_TARGET_H_ 00034 00035 00036 //================================================================================================== 00037 //=== System headers 00038 //================================================================================================== 00039 #include <sys/types.h> 00040 #include <pthread.h> 00041 #include <dirent.h> 00042 00043 00044 //================================================================================================== 00045 //=== Import / export 00046 //================================================================================================== 00049 #define EXPORT __attribute__ ((visibility("default"))) 00050 00053 #define IMPORT 00054 00055 // \cond DOXYGEN_DOCUMENT_NEVER 00056 #if UT_IMPORT 00057 #define UT_EXPORT IMPORT 00058 #else 00059 #define UT_EXPORT EXPORT 00060 #endif 00061 // \endcond 00062 00063 00064 //================================================================================================== 00065 //=== Basic flags 00066 //================================================================================================== 00067 // \cond DOXYGEN_DOCUMENT_NEVER 00068 #ifndef LINUX 00069 #define LINUX 1 00070 #endif 00071 // \endcond 00072 00073 00074 //================================================================================================== 00075 //=== Behavioral flags 00076 //================================================================================================== 00077 #if __i386 00081 #define TARGET_CPU_LITTLE_ENDIAN 1 00082 00087 #define TARGET_CPU_ALLOW_UNALIGNED_ACCESS 1 00088 00093 #define TARGET_CPU_FAST_INTEGER_MOD 1 00094 00097 #define POINTER_IS_32_BIT 1 00098 00099 // \cond DOXYGEN_DOCUMENT_NEVER 00100 #define LINUX_i386 1 00101 // \endcond 00102 #elif __x86_64 00103 #define TARGET_CPU_LITTLE_ENDIAN 1 00104 #define TARGET_CPU_ALLOW_UNALIGNED_ACCESS 1 00105 #define TARGET_CPU_FAST_INTEGER_MOD 1 00106 #define POINTER_IS_64_BIT 1 00107 #define LINUX_x86_64 1 00108 #else 00109 #error "Must define target CPU endianness and access alignment rules" 00110 #endif 00111 00113 #define c_os_timer_reliable_ms 3 00114 00116 #define c_os_timer_resolution_ms 1 00117 00118 // \cond DOXYGEN_DOCUMENT_NEVER 00119 #define c_target_native_line_ending eLINEENDING_unix 00120 // \endcond 00121 00122 00123 //================================================================================================== 00124 //=== Implementation support types 00125 //================================================================================================== 00126 00128 typedef pthread_t thread_id_t; 00129 00130 // \cond DOXYGEN_DOCUMENT_NEVER 00131 #define INVALID_PTHREAD 0xffffffff 00132 // \endcond 00133 00135 typedef DIR* dir_t; 00136 00138 typedef off_t fileoff_t; 00139 00140 #if __USE_FILE_OFFSET64 00144 #define c_fileoff_printf_format "%lld" 00145 00149 #define c_fileoff_printf_hex_format "%llx" 00150 #else 00151 #define c_fileoff_printf_format "%d" 00152 #define c_fileoff_printf_hex_format "%x" 00153 #endif 00154 00155 00156 EXTERN_C_BEGIN 00157 // \cond DOXYGEN_DOCUMENT_NEVER 00158 00159 00160 //================================================================================================== 00161 //=== Fix warnings about C-style and illegal casts 00162 //================================================================================================== 00163 00164 #if __cplusplus 00165 #ifdef towlower 00166 #undef towlower 00167 extern wint_t towlower (wint_t __wc) __THROW; 00168 #endif 00169 #endif 00170 00171 00172 //================================================================================================== 00173 //=== Missing case-insensitive string function names 00174 //================================================================================================== 00175 #define stricmp strcasecmp 00176 #define strnicmp strncasecmp 00177 #define stristr strcasestr 00178 00179 00180 //================================================================================================== 00181 //=== Fix POSIX spec violations 00182 //================================================================================================== 00183 #define strerror_r strerror_r_FIXED 00184 extern int strerror_r_FIXED( int errnum, char* buf, size_t n ); 00185 00186 00187 // \endcond 00188 EXTERN_C_END