1 /* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- 2 * 3 * Copyright (c) 2014-2015 Datalight, Inc. 4 * All Rights Reserved Worldwide. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; use version 2 of the License. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but "AS-IS," WITHOUT ANY WARRANTY; without even the implied warranty 12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 20 /* Businesses and individuals that for commercial or other reasons cannot 21 * comply with the terms of the GPLv2 license may obtain a commercial license 22 * before incorporating Reliance Edge into proprietary software for 23 * distribution in any form. Visit http://www.datalight.com/reliance-edge for 24 * more information. 25 */ 26 27 /** @file 28 * @brief Defines macros which make the Reliance Edge POSIX-like API look more 29 * like the actual POSIX API. 30 * 31 * This file is intended for porting POSIX file system tests; it is not 32 * intended for application use. 33 */ 34 #ifndef REDPOSIXCOMPAT_H 35 #define REDPOSIXCOMPAT_H 36 37 38 #ifndef assert 39 #define assert( x ) REDASSERT( x ) 40 #endif 41 42 43 #undef O_RDONLY 44 #undef O_WRONLY 45 #undef O_RDWR 46 #undef O_APPEND 47 #undef O_CREAT 48 #undef O_EXCL 49 #undef O_TRUNC 50 #define O_RDONLY RED_O_RDONLY 51 #define O_WRONLY RED_O_WRONLY 52 #define O_RDWR RED_O_RDWR 53 #define O_APPEND RED_O_APPEND 54 #define O_CREAT RED_O_CREAT 55 #define O_EXCL RED_O_EXCL 56 #define O_TRUNC RED_O_TRUNC 57 58 #undef SEEK_SET 59 #undef SEEK_CUR 60 #undef SEEK_END 61 #define SEEK_SET RED_SEEK_SET 62 #define SEEK_CUR RED_SEEK_CUR 63 #define SEEK_END RED_SEEK_END 64 65 /* Old-fashioned Linux seek names. 66 */ 67 #undef L_SET 68 #undef L_INCR 69 #undef L_XTND 70 #define L_SET SEEK_SET 71 #define L_INCR SEEK_CUR 72 #define L_XTND SEEK_END 73 74 #undef S_IFDIR 75 #undef S_IFREG 76 #undef S_ISDIR 77 #undef S_ISREG 78 #define S_IFDIR RED_S_IFDIR 79 #define S_IFREG RED_S_IFREG 80 #define S_ISDIR( m ) RED_S_ISDIR( m ) 81 #define S_ISREG( m ) RED_S_ISREG( m ) 82 83 #undef ST_RDONLY 84 #undef ST_NOSUID 85 #define ST_RDONLY RED_ST_RDONLY 86 #define ST_NOSUID RED_ST_NOSUID 87 88 #undef open 89 #undef creat 90 #undef unlink 91 #undef mkdir 92 #undef rmdir 93 #undef rename 94 #undef link 95 #undef close 96 #undef read 97 #undef write 98 #undef fsync 99 #undef fdatasync 100 #undef lseek 101 #undef ftruncate 102 #undef fstat 103 #undef opendir 104 #undef readdir 105 #undef rewinddir 106 #undef closedir 107 #define open( path, oflag ) red_open( path, oflag ) 108 #define creat( path, mode ) open( path, O_WRONLY | O_CREAT | O_TRUNC ) 109 #define unlink( path ) red_unlink( path ) 110 #define mkdir( path ) red_mkdir( path ) 111 #define rmdir( path ) red_rmdir( path ) 112 #define rename( old, new ) red_rename( old, new ) 113 #define link( path, hardlink ) red_link( path, hardlink ) 114 #define close( fd ) red_close( fd ) 115 #define read( fd, buf, len ) red_read( fd, buf, len ) 116 #define write( fd, buf, len ) red_write( fd, buf, len ) 117 #define fsync( fd ) red_fsync( fd ) 118 #define fdatasync( fd ) fsync( fd ) 119 #define lseek( fd, offset, whence ) red_lseek( fd, offset, whence ) 120 #define lseek64( fd, offset, whence ) lseek( fd, offset, whence ) 121 #define ftruncate( fd, size ) red_ftruncate( fd, size ) 122 #define fstat( fd, stat ) red_fstat( fd, stat ) 123 #define fstat64( fd, stat ) fstat( fd, stat ) 124 #define opendir( path ) red_opendir( path ) 125 #define readdir( dirp ) red_readdir( dirp ) 126 #define readdir64( dirp ) readdir( dirp ) 127 #define rewinddir( dirp ) red_rewinddir( dirp ) 128 #define closedir( dirp ) red_closedir( dirp ) 129 130 #undef DIR 131 #define DIR REDDIR 132 133 #undef errno 134 #define errno ( *( int * ) red_errnoptr() ) 135 136 #undef memcpy 137 #undef memmove 138 #undef memset 139 #undef strlen 140 #undef strncmp 141 #undef strcmp 142 #undef strncpy 143 #define memcpy( d, s, l ) RedMemCpy( d, s, ( uint32_t ) ( l ) ) 144 #define memmove( d, s, l ) RedMemMove( d, s, ( uint32_t ) ( l ) ) 145 #define memset( d, c, l ) RedMemSet( d, ( uint8_t ) ( c ), ( uint32_t ) ( l ) ) 146 #define strlen( s ) RedStrLen( s ) 147 #define strncmp( s1, s2, l ) RedStrNCmp( s1, s2, ( uint32_t ) ( l ) ) 148 #define strcmp( s1, s2 ) RedStrCmp( s1, s2 ) 149 #define strncpy( d, s, l ) RedStrNCpy( d, s, ( uint32_t ) ( l ) ) 150 151 152 #endif /* ifndef REDPOSIXCOMPAT_H */ 153