diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/libbb.h | 70 |
1 files changed, 48 insertions, 22 deletions
diff --git a/include/libbb.h b/include/libbb.h index a7c770400..bc86e5faf 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -61,30 +61,56 @@ | |||
61 | #define PATH_MAX 256 | 61 | #define PATH_MAX 256 |
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | /* Not (yet) used, but tested to work correctly | ||
65 | #define MAXINT(T) (T)( \ | ||
66 | ((T)-1) > 0 \ | ||
67 | ? (T)-1 \ | ||
68 | : (T)~((T)1 << (sizeof(T)*8-1)) \ | ||
69 | ) | ||
70 | |||
71 | #define MININT(T) (T)( \ | ||
72 | ((T)-1) > 0 \ | ||
73 | ? (T)0 \ | ||
74 | : ((T)1 << (sizeof(T)*8-1)) \ | ||
75 | ) | ||
76 | */ | ||
77 | |||
64 | /* Large file support */ | 78 | /* Large file support */ |
65 | #ifdef CONFIG_LFS | 79 | /* Note that CONFIG_LFS forces bbox to be built with all common ops |
66 | # define FILEOFF_TYPE off64_t | 80 | * (stat, lseek etc) mapped to "largefile" variants by libc. |
67 | # define FILEOFF_FMT "%lld" | 81 | * Practically it means that open() automatically has O_LARGEFILE added |
68 | # define LSEEK lseek64 | 82 | * and all filesize/file_offset parameters and struct members are "large" |
69 | # define STAT stat64 | 83 | * (in today's world - signed 64bit). For full support of large files, |
70 | # define LSTAT lstat64 | 84 | * we need a few helper #defines (below) and careful use of off_t |
71 | # define STRUCT_STAT struct stat64 | 85 | * instead of int/ssize_t. No lseek64(), O_LARGEFILE etc necessary */ |
72 | # define STRTOOFF strtoll | 86 | #if ENBALE_LFS |
73 | # define SAFE_STRTOOFF safe_strtoll | 87 | /* CONFIG_LFS is on */ |
88 | # if ULONG_MAX > 0xffffffff | ||
89 | /* "long" is long enough on this system */ | ||
90 | # define STRTOOFF strtol | ||
91 | # define SAFE_STRTOOFF safe_strtol | ||
92 | # define OFF_FMT "%ld" | ||
93 | # else | ||
94 | /* "long" is too short, need "lomg long" */ | ||
95 | # define STRTOOFF strtoll | ||
96 | # define SAFE_STRTOOFF safe_strtoll | ||
97 | # define OFF_FMT "%lld" | ||
98 | # endif | ||
74 | #else | 99 | #else |
75 | # define FILEOFF_TYPE off_t | 100 | # if 0 /* UINT_MAX == 0xffffffff */ |
76 | # define FILEOFF_FMT "%ld" | 101 | /* Doesn't work. off_t is a long. gcc will throw warnings on printf("%d", off_t) |
77 | # define LSEEK lseek | 102 | * even if long==int on this arch. Crap... */ |
78 | # define STAT stat | 103 | # define STRTOOFF strtol |
79 | # define LSTAT lstat | 104 | # define SAFE_STRTOOFF safe_strtoi |
80 | # define STRUCT_STAT struct stat | 105 | # define OFF_FMT "%d" |
81 | # define STRTOOFF strtol | 106 | # else |
82 | # define SAFE_STRTOOFF safe_strtol | 107 | # define STRTOOFF strtol |
83 | /* Do we need to undefine O_LARGEFILE? */ | 108 | # define SAFE_STRTOOFF safe_strtol |
109 | # define OFF_FMT "%ld" | ||
110 | # endif | ||
84 | #endif | 111 | #endif |
85 | /* scary. better ideas? (but do *test* them first!) */ | 112 | /* scary. better ideas? (but do *test* them first!) */ |
86 | #define MAX_FILEOFF_TYPE \ | 113 | #define OFF_T_MAX ((off_t)~((off_t)1 << (sizeof(off_t)*8-1))) |
87 | ((FILEOFF_TYPE)~((FILEOFF_TYPE)1 << (sizeof(FILEOFF_TYPE)*8-1))) | ||
88 | 114 | ||
89 | /* Some useful definitions */ | 115 | /* Some useful definitions */ |
90 | #undef FALSE | 116 | #undef FALSE |
@@ -203,8 +229,8 @@ extern char *find_block_device(char *path); | |||
203 | extern char *bb_get_line_from_file(FILE *file); | 229 | extern char *bb_get_line_from_file(FILE *file); |
204 | extern char *bb_get_chomped_line_from_file(FILE *file); | 230 | extern char *bb_get_chomped_line_from_file(FILE *file); |
205 | extern char *bb_get_chunk_from_file(FILE *file, int *end); | 231 | extern char *bb_get_chunk_from_file(FILE *file, int *end); |
206 | extern int bb_copyfd_size(int fd1, int fd2, const off_t size); | 232 | extern off_t bb_copyfd_size(int fd1, int fd2, off_t size); |
207 | extern int bb_copyfd_eof(int fd1, int fd2); | 233 | extern off_t bb_copyfd_eof(int fd1, int fd2); |
208 | extern char bb_process_escape_sequence(const char **ptr); | 234 | extern char bb_process_escape_sequence(const char **ptr); |
209 | extern char *bb_get_last_path_component(char *path); | 235 | extern char *bb_get_last_path_component(char *path); |
210 | extern FILE *bb_wfopen(const char *path, const char *mode); | 236 | extern FILE *bb_wfopen(const char *path, const char *mode); |