1
by brian
clean slate |
1 |
/* Copyright (C) 2000-2003 MySQL AB
|
2 |
||
3 |
This program is free software; you can redistribute it and/or modify
|
|
4 |
it under the terms of the GNU General Public License as published by
|
|
5 |
the Free Software Foundation; version 2 of the License.
|
|
6 |
||
7 |
This program is distributed in the hope that it will be useful,
|
|
8 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
GNU General Public License for more details.
|
|
11 |
||
12 |
You should have received a copy of the GNU General Public License
|
|
13 |
along with this program; if not, write to the Free Software
|
|
14 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
15 |
||
16 |
#ifndef _my_sys_h
|
|
17 |
#define _my_sys_h
|
|
18 |
C_MODE_START
|
|
19 |
||
20 |
#ifdef HAVE_AIOWAIT
|
|
21 |
#include <sys/asynch.h> /* Used by record-cache */ |
|
22 |
typedef struct my_aio_result { |
|
23 |
aio_result_t result; |
|
24 |
int pending; |
|
25 |
} my_aio_result; |
|
26 |
#endif
|
|
27 |
||
12.4.2
by Stewart Smith
my_errno => errno |
28 |
#include <errno.h> |
29 |
#define my_errno (errno)
|
|
30 |
||
31 |
#ifdef THREAD
|
|
1
by brian
clean slate |
32 |
#include <my_pthread.h> |
33 |
#endif
|
|
34 |
||
35 |
#include <m_ctype.h> /* for CHARSET_INFO */ |
|
36 |
#include <stdarg.h> |
|
37 |
#include <typelib.h> |
|
38 |
||
39 |
#define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
|
|
40 |
#define MY_INIT(name); { my_progname= name; my_init(); }
|
|
41 |
||
42 |
#define ERRMSGSIZE (SC_MAXWIDTH) /* Max length of a error message */ |
|
43 |
#define NRERRBUFFS (2) /* Buffers for parameters */ |
|
44 |
#define MY_FILE_ERROR ((size_t) -1)
|
|
45 |
||
46 |
/* General bitmaps for my_func's */
|
|
47 |
#define MY_FFNF 1 /* Fatal if file not found */ |
|
48 |
#define MY_FNABP 2 /* Fatal if not all bytes read/writen */ |
|
49 |
#define MY_NABP 4 /* Error if not all bytes read/writen */ |
|
50 |
#define MY_FAE 8 /* Fatal if any error */ |
|
51 |
#define MY_WME 16 /* Write message on error */ |
|
52 |
#define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */ |
|
53 |
#define MY_IGNORE_BADFD 32 /* my_sync: ignore 'bad descriptor' errors */ |
|
54 |
#define MY_SYNC_DIR 1024 /* my_create/delete/rename: sync directory */ |
|
55 |
#define MY_RAID 64 /* Support for RAID */ |
|
56 |
#define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */ |
|
57 |
#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */ |
|
58 |
#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */ |
|
59 |
#define MY_COPYTIME 64 /* my_redel() copys time */ |
|
60 |
#define MY_DELETE_OLD 256 /* my_create_with_symlink() */ |
|
61 |
#define MY_RESOLVE_LINK 128 /* my_realpath(); Only resolve links */ |
|
62 |
#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */ |
|
63 |
#define MY_REDEL_MAKE_BACKUP 256
|
|
64 |
#define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */ |
|
65 |
#define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */ |
|
66 |
#define MY_ZEROFILL 32 /* my_malloc(), fill array with zero */ |
|
67 |
#define MY_ALLOW_ZERO_PTR 64 /* my_realloc() ; zero ptr -> malloc */ |
|
68 |
#define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */ |
|
69 |
#define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */ |
|
70 |
#define MY_DONT_OVERWRITE_FILE 1024 /* my_copy: Don't overwrite file */ |
|
71 |
#define MY_THREADSAFE 2048 /* my_seek(): lock fd mutex */ |
|
72 |
||
73 |
#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */ |
|
74 |
#define MY_GIVE_INFO 2 /* Give time info about process*/ |
|
75 |
#define MY_DONT_FREE_DBUG 4 /* Do not call DBUG_END() in my_end() */ |
|
76 |
||
77 |
#define MY_REMOVE_NONE 0 /* Params for modify_defaults_file */ |
|
78 |
#define MY_REMOVE_OPTION 1
|
|
79 |
#define MY_REMOVE_SECTION 2
|
|
80 |
||
81 |
#define ME_HIGHBYTE 8 /* Shift for colours */ |
|
82 |
#define ME_NOCUR 1 /* Don't use curses message */ |
|
83 |
#define ME_OLDWIN 2 /* Use old window */ |
|
84 |
#define ME_BELL 4 /* Ring bell then printing message */ |
|
85 |
#define ME_HOLDTANG 8 /* Don't delete last keys */ |
|
86 |
#define ME_WAITTOT 16 /* Wait for errtime secs of for a action */ |
|
87 |
#define ME_WAITTANG 32 /* Wait for a user action */ |
|
88 |
#define ME_NOREFRESH 64 /* Dont refresh screen */ |
|
89 |
#define ME_NOINPUT 128 /* Dont use the input libary */ |
|
90 |
#define ME_COLOUR1 ((1 << ME_HIGHBYTE)) /* Possibly error-colours */ |
|
91 |
#define ME_COLOUR2 ((2 << ME_HIGHBYTE))
|
|
92 |
#define ME_COLOUR3 ((3 << ME_HIGHBYTE))
|
|
93 |
#define ME_FATALERROR 1024 /* Fatal statement error */ |
|
94 |
||
95 |
/* Bits in last argument to fn_format */
|
|
96 |
#define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */ |
|
97 |
#define MY_REPLACE_EXT 2 /* replace extension with 'ext' */ |
|
98 |
#define MY_UNPACK_FILENAME 4 /* Unpack name (~ -> home) */ |
|
99 |
#define MY_PACK_FILENAME 8 /* Pack name (home -> ~) */ |
|
100 |
#define MY_RESOLVE_SYMLINKS 16 /* Resolve all symbolic links */ |
|
101 |
#define MY_RETURN_REAL_PATH 32 /* return full path for file */ |
|
102 |
#define MY_SAFE_PATH 64 /* Return NULL if too long path */ |
|
103 |
#define MY_RELATIVE_PATH 128 /* name is relative to 'dir' */ |
|
104 |
#define MY_APPEND_EXT 256 /* add 'ext' as additional extension*/ |
|
105 |
||
106 |
||
107 |
/* My seek flags */
|
|
108 |
#define MY_SEEK_SET 0
|
|
109 |
#define MY_SEEK_CUR 1
|
|
110 |
#define MY_SEEK_END 2
|
|
111 |
||
112 |
/* Some constants */
|
|
113 |
#define MY_WAIT_FOR_USER_TO_FIX_PANIC 60 /* in seconds */ |
|
114 |
#define MY_WAIT_GIVE_USER_A_MESSAGE 10 /* Every 10 times of prev */ |
|
115 |
#define MIN_COMPRESS_LENGTH 50 /* Don't compress small bl. */ |
|
116 |
#define DFLT_INIT_HITS 3
|
|
117 |
||
118 |
/* root_alloc flags */
|
|
119 |
#define MY_KEEP_PREALLOC 1
|
|
120 |
#define MY_MARK_BLOCKS_FREE 2 /* move used to free list and reuse them */ |
|
121 |
||
122 |
/* Internal error numbers (for assembler functions) */
|
|
123 |
#define MY_ERRNO_EDOM 33
|
|
124 |
#define MY_ERRNO_ERANGE 34
|
|
125 |
||
126 |
/* Bits for get_date timeflag */
|
|
127 |
#define GETDATE_DATE_TIME 1
|
|
128 |
#define GETDATE_SHORT_DATE 2
|
|
129 |
#define GETDATE_HHMMSSTIME 4
|
|
130 |
#define GETDATE_GMT 8
|
|
131 |
#define GETDATE_FIXEDLENGTH 16
|
|
132 |
||
133 |
/* defines when allocating data */
|
|
134 |
#ifdef SAFEMALLOC
|
|
135 |
#else
|
|
136 |
#define my_checkmalloc()
|
|
137 |
#undef TERMINATE
|
|
138 |
#define TERMINATE(A,B) {}
|
|
139 |
#define QUICK_SAFEMALLOC
|
|
140 |
#define NORMAL_SAFEMALLOC
|
|
141 |
extern void *my_malloc(size_t Size,myf MyFlags); |
|
142 |
#define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG )
|
|
143 |
extern void *my_realloc(void *oldpoint, size_t Size, myf MyFlags); |
|
144 |
extern void my_no_flags_free(void *ptr); |
|
145 |
extern void *my_memdup(const void *from,size_t length,myf MyFlags); |
|
146 |
extern char *my_strdup(const char *from,myf MyFlags); |
|
147 |
extern char *my_strndup(const char *from, size_t length, |
|
148 |
myf MyFlags); |
|
149 |
/* we do use FG (as a no-op) in below so that a typo on FG is caught */
|
|
150 |
#define my_free(PTR,FG) ((void)FG,my_no_flags_free(PTR))
|
|
151 |
#define CALLER_INFO_PROTO /* nothing */ |
|
152 |
#define CALLER_INFO /* nothing */ |
|
153 |
#define ORIG_CALLER_INFO /* nothing */ |
|
154 |
#define TRASH(A,B) /* nothing */ |
|
155 |
#endif
|
|
156 |
||
157 |
#ifdef HAVE_ALLOCA
|
|
158 |
#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && ! defined(alloca)
|
|
159 |
#define alloca __builtin_alloca
|
|
160 |
#endif /* GNUC */ |
|
161 |
#define my_alloca(SZ) alloca((size_t) (SZ))
|
|
162 |
#define my_afree(PTR) {}
|
|
163 |
#else
|
|
164 |
#define my_alloca(SZ) my_malloc(SZ,MYF(0))
|
|
165 |
#define my_afree(PTR) my_free(PTR,MYF(MY_WME))
|
|
166 |
#endif /* HAVE_ALLOCA */ |
|
167 |
||
168 |
#ifndef errno /* did we already get it? */ |
|
169 |
#ifdef HAVE_ERRNO_AS_DEFINE
|
|
170 |
#include <errno.h> /* errno is a define */ |
|
171 |
#else
|
|
172 |
extern int errno; /* declare errno */ |
|
173 |
#endif
|
|
174 |
#endif /* #ifndef errno */ |
|
175 |
extern char errbuff[NRERRBUFFS][ERRMSGSIZE]; |
|
176 |
extern char *home_dir; /* Home directory for user */ |
|
177 |
extern const char *my_progname; /* program-name (printed in errors) */ |
|
178 |
extern char curr_dir[]; /* Current directory for user */ |
|
179 |
extern void (*error_handler_hook)(uint my_err, const char *str,myf MyFlags); |
|
180 |
extern void (*fatal_error_handler_hook)(uint my_err, const char *str, |
|
181 |
myf MyFlags); |
|
182 |
extern uint my_file_limit; |
|
183 |
extern ulong my_thread_stack_size; |
|
184 |
||
185 |
/* charsets */
|
|
186 |
extern CHARSET_INFO *default_charset_info; |
|
187 |
extern CHARSET_INFO *all_charsets[256]; |
|
188 |
extern CHARSET_INFO compiled_charsets[]; |
|
189 |
||
190 |
/* statistics */
|
|
191 |
extern ulong my_file_opened,my_stream_opened, my_tmp_file_created; |
|
192 |
extern ulong my_file_total_opened; |
|
193 |
extern uint mysys_usage_id; |
|
194 |
extern my_bool my_init_done; |
|
195 |
||
196 |
/* Point to current my_message() */
|
|
197 |
extern void (*my_sigtstp_cleanup)(void), |
|
198 |
/* Executed before jump to shell */
|
|
199 |
(*my_sigtstp_restart)(void), |
|
200 |
(*my_abort_hook)(int); |
|
201 |
/* Executed when comming from shell */
|
|
202 |
extern int my_umask, /* Default creation mask */ |
|
203 |
my_umask_dir, |
|
204 |
my_recived_signals, /* Signals we have got */ |
|
205 |
my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */ |
|
206 |
my_dont_interrupt; /* call remember_intr when set */ |
|
207 |
extern my_bool mysys_uses_curses, my_use_symdir; |
|
208 |
extern ulong sf_malloc_cur_memory, sf_malloc_max_memory; |
|
209 |
||
210 |
extern ulong my_default_record_cache_size; |
|
211 |
extern my_bool my_disable_locking, my_disable_async_io, |
|
212 |
my_disable_flush_key_blocks, my_disable_symlinks; |
|
213 |
extern char wild_many, wild_one, wild_prefix; |
|
214 |
extern const char *charsets_dir; |
|
215 |
/* from default.c */
|
|
216 |
extern char *my_defaults_extra_file; |
|
217 |
extern const char *my_defaults_group_suffix; |
|
218 |
extern const char *my_defaults_file; |
|
219 |
||
220 |
extern my_bool timed_mutexes; |
|
221 |
||
222 |
typedef struct wild_file_pack /* Struct to hold info when selecting files */ |
|
223 |
{
|
|
224 |
uint wilds; /* How many wildcards */ |
|
225 |
uint not_pos; /* Start of not-theese-files */ |
|
226 |
char * *wild; /* Pointer to wildcards */ |
|
227 |
} WF_PACK; |
|
228 |
||
229 |
enum loglevel { |
|
230 |
ERROR_LEVEL, |
|
231 |
WARNING_LEVEL, |
|
232 |
INFORMATION_LEVEL
|
|
233 |
};
|
|
234 |
||
235 |
enum cache_type |
|
236 |
{
|
|
237 |
TYPE_NOT_SET= 0, READ_CACHE, WRITE_CACHE, |
|
238 |
SEQ_READ_APPEND /* sequential read or append */, |
|
239 |
READ_FIFO, READ_NET,WRITE_NET}; |
|
240 |
||
241 |
enum flush_type |
|
242 |
{
|
|
243 |
FLUSH_KEEP, /* flush block and keep it in the cache */ |
|
244 |
FLUSH_RELEASE, /* flush block and remove it from the cache */ |
|
245 |
FLUSH_IGNORE_CHANGED, /* remove block from the cache */ |
|
246 |
/*
|
|
247 |
As my_disable_flush_pagecache_blocks is always 0, the following option
|
|
248 |
is strictly equivalent to FLUSH_KEEP
|
|
249 |
*/
|
|
250 |
FLUSH_FORCE_WRITE
|
|
251 |
};
|
|
252 |
||
253 |
typedef struct st_record_cache /* Used when cacheing records */ |
|
254 |
{
|
|
255 |
File file; |
|
256 |
int rc_seek,error,inited; |
|
257 |
uint rc_length,read_length,reclength; |
|
258 |
my_off_t rc_record_pos,end_of_file; |
|
259 |
uchar *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos; |
|
260 |
#ifdef HAVE_AIOWAIT
|
|
261 |
int use_async_io; |
|
262 |
my_aio_result aio_result; |
|
263 |
#endif
|
|
264 |
enum cache_type type; |
|
265 |
} RECORD_CACHE; |
|
266 |
||
267 |
enum file_type |
|
268 |
{
|
|
269 |
UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN, |
|
270 |
FILE_BY_MKSTEMP, FILE_BY_DUP |
|
271 |
};
|
|
272 |
||
273 |
struct st_my_file_info |
|
274 |
{
|
|
275 |
char * name; |
|
276 |
enum file_type type; |
|
277 |
#if defined(THREAD) && !defined(HAVE_PREAD)
|
|
278 |
pthread_mutex_t mutex; |
|
279 |
#endif
|
|
280 |
};
|
|
281 |
||
282 |
extern struct st_my_file_info *my_file_info; |
|
283 |
||
284 |
typedef struct st_dynamic_array |
|
285 |
{
|
|
286 |
uchar *buffer; |
|
287 |
uint elements,max_element; |
|
288 |
uint alloc_increment; |
|
289 |
uint size_of_element; |
|
290 |
} DYNAMIC_ARRAY; |
|
291 |
||
292 |
typedef struct st_my_tmpdir |
|
293 |
{
|
|
294 |
DYNAMIC_ARRAY full_list; |
|
295 |
char **list; |
|
296 |
uint cur, max; |
|
297 |
#ifdef THREAD
|
|
298 |
pthread_mutex_t mutex; |
|
299 |
#endif
|
|
300 |
} MY_TMPDIR; |
|
301 |
||
302 |
typedef struct st_dynamic_string |
|
303 |
{
|
|
304 |
char *str; |
|
305 |
size_t length,max_length,alloc_increment; |
|
306 |
} DYNAMIC_STRING; |
|
307 |
||
308 |
struct st_io_cache; |
|
309 |
typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*); |
|
310 |
||
311 |
#ifdef THREAD
|
|
312 |
typedef struct st_io_cache_share |
|
313 |
{
|
|
314 |
pthread_mutex_t mutex; /* To sync on reads into buffer. */ |
|
315 |
pthread_cond_t cond; /* To wait for signals. */ |
|
316 |
pthread_cond_t cond_writer; /* For a synchronized writer. */ |
|
317 |
/* Offset in file corresponding to the first byte of buffer. */
|
|
318 |
my_off_t pos_in_file; |
|
319 |
/* If a synchronized write cache is the source of the data. */
|
|
320 |
struct st_io_cache *source_cache; |
|
321 |
uchar *buffer; /* The read buffer. */ |
|
322 |
uchar *read_end; /* Behind last valid byte of buffer. */ |
|
323 |
int running_threads; /* threads not in lock. */ |
|
324 |
int total_threads; /* threads sharing the cache. */ |
|
325 |
int error; /* Last error. */ |
|
326 |
#ifdef NOT_YET_IMPLEMENTED
|
|
327 |
/* whether the structure should be free'd */
|
|
328 |
my_bool alloced; |
|
329 |
#endif
|
|
330 |
} IO_CACHE_SHARE; |
|
331 |
#endif
|
|
332 |
||
333 |
typedef struct st_io_cache /* Used when cacheing files */ |
|
334 |
{
|
|
335 |
/* Offset in file corresponding to the first byte of uchar* buffer. */
|
|
336 |
my_off_t pos_in_file; |
|
337 |
/*
|
|
338 |
The offset of end of file for READ_CACHE and WRITE_CACHE.
|
|
339 |
For SEQ_READ_APPEND it the maximum of the actual end of file and
|
|
340 |
the position represented by read_end.
|
|
341 |
*/
|
|
342 |
my_off_t end_of_file; |
|
343 |
/* Points to current read position in the buffer */
|
|
344 |
uchar *read_pos; |
|
345 |
/* the non-inclusive boundary in the buffer for the currently valid read */
|
|
346 |
uchar *read_end; |
|
347 |
uchar *buffer; /* The read buffer */ |
|
348 |
/* Used in ASYNC_IO */
|
|
349 |
uchar *request_pos; |
|
350 |
||
351 |
/* Only used in WRITE caches and in SEQ_READ_APPEND to buffer writes */
|
|
352 |
uchar *write_buffer; |
|
353 |
/*
|
|
354 |
Only used in SEQ_READ_APPEND, and points to the current read position
|
|
355 |
in the write buffer. Note that reads in SEQ_READ_APPEND caches can
|
|
356 |
happen from both read buffer (uchar* buffer) and write buffer
|
|
357 |
(uchar* write_buffer).
|
|
358 |
*/
|
|
359 |
uchar *append_read_pos; |
|
360 |
/* Points to current write position in the write buffer */
|
|
361 |
uchar *write_pos; |
|
362 |
/* The non-inclusive boundary of the valid write area */
|
|
363 |
uchar *write_end; |
|
364 |
||
365 |
/*
|
|
366 |
Current_pos and current_end are convenience variables used by
|
|
367 |
my_b_tell() and other routines that need to know the current offset
|
|
368 |
current_pos points to &write_pos, and current_end to &write_end in a
|
|
369 |
WRITE_CACHE, and &read_pos and &read_end respectively otherwise
|
|
370 |
*/
|
|
371 |
uchar **current_pos, **current_end; |
|
372 |
#ifdef THREAD
|
|
373 |
/*
|
|
374 |
The lock is for append buffer used in SEQ_READ_APPEND cache
|
|
375 |
need mutex copying from append buffer to read buffer.
|
|
376 |
*/
|
|
377 |
pthread_mutex_t append_buffer_lock; |
|
378 |
/*
|
|
379 |
The following is used when several threads are reading the
|
|
380 |
same file in parallel. They are synchronized on disk
|
|
381 |
accesses reading the cached part of the file asynchronously.
|
|
382 |
It should be set to NULL to disable the feature. Only
|
|
383 |
READ_CACHE mode is supported.
|
|
384 |
*/
|
|
385 |
IO_CACHE_SHARE *share; |
|
386 |
#endif
|
|
387 |
/*
|
|
388 |
A caller will use my_b_read() macro to read from the cache
|
|
389 |
if the data is already in cache, it will be simply copied with
|
|
390 |
memcpy() and internal variables will be accordinging updated with
|
|
391 |
no functions invoked. However, if the data is not fully in the cache,
|
|
392 |
my_b_read() will call read_function to fetch the data. read_function
|
|
393 |
must never be invoked directly.
|
|
394 |
*/
|
|
395 |
int (*read_function)(struct st_io_cache *,uchar *,size_t); |
|
396 |
/*
|
|
397 |
Same idea as in the case of read_function, except my_b_write() needs to
|
|
398 |
be replaced with my_b_append() for a SEQ_READ_APPEND cache
|
|
399 |
*/
|
|
400 |
int (*write_function)(struct st_io_cache *,const uchar *,size_t); |
|
401 |
/*
|
|
402 |
Specifies the type of the cache. Depending on the type of the cache
|
|
403 |
certain operations might not be available and yield unpredicatable
|
|
404 |
results. Details to be documented later
|
|
405 |
*/
|
|
406 |
enum cache_type type; |
|
407 |
/*
|
|
408 |
Callbacks when the actual read I/O happens. These were added and
|
|
409 |
are currently used for binary logging of LOAD DATA INFILE - when a
|
|
410 |
block is read from the file, we create a block create/append event, and
|
|
411 |
when IO_CACHE is closed, we create an end event. These functions could,
|
|
412 |
of course be used for other things
|
|
413 |
*/
|
|
414 |
IO_CACHE_CALLBACK pre_read; |
|
415 |
IO_CACHE_CALLBACK post_read; |
|
416 |
IO_CACHE_CALLBACK pre_close; |
|
417 |
/*
|
|
418 |
Counts the number of times, when we were forced to use disk. We use it to
|
|
419 |
increase the binlog_cache_disk_use status variable.
|
|
420 |
*/
|
|
421 |
ulong disk_writes; |
|
422 |
void* arg; /* for use by pre/post_read */ |
|
423 |
char *file_name; /* if used with 'open_cached_file' */ |
|
424 |
char *dir,*prefix; |
|
425 |
File file; /* file descriptor */ |
|
426 |
/*
|
|
427 |
seek_not_done is set by my_b_seek() to inform the upcoming read/write
|
|
428 |
operation that a seek needs to be preformed prior to the actual I/O
|
|
429 |
error is 0 if the cache operation was successful, -1 if there was a
|
|
430 |
"hard" error, and the actual number of I/O-ed bytes if the read/write was
|
|
431 |
partial.
|
|
432 |
*/
|
|
433 |
int seek_not_done,error; |
|
434 |
/* buffer_length is memory size allocated for buffer or write_buffer */
|
|
435 |
size_t buffer_length; |
|
436 |
/* read_length is the same as buffer_length except when we use async io */
|
|
437 |
size_t read_length; |
|
438 |
myf myflags; /* Flags used to my_read/my_write */ |
|
439 |
/*
|
|
440 |
alloced_buffer is 1 if the buffer was allocated by init_io_cache() and
|
|
441 |
0 if it was supplied by the user.
|
|
442 |
Currently READ_NET is the only one that will use a buffer allocated
|
|
443 |
somewhere else
|
|
444 |
*/
|
|
445 |
my_bool alloced_buffer; |
|
446 |
#ifdef HAVE_AIOWAIT
|
|
447 |
/*
|
|
448 |
As inidicated by ifdef, this is for async I/O, which is not currently
|
|
449 |
used (because it's not reliable on all systems)
|
|
450 |
*/
|
|
451 |
uint inited; |
|
452 |
my_off_t aio_read_pos; |
|
453 |
my_aio_result aio_result; |
|
454 |
#endif
|
|
455 |
} IO_CACHE; |
|
456 |
||
457 |
typedef int (*qsort2_cmp)(const void *, const void *, const void *); |
|
458 |
||
459 |
/* defines for mf_iocache */
|
|
460 |
||
461 |
/* Test if buffer is inited */
|
|
462 |
#define my_b_clear(info) (info)->buffer=0
|
|
463 |
#define my_b_inited(info) (info)->buffer
|
|
464 |
#define my_b_EOF INT_MIN
|
|
465 |
||
466 |
#define my_b_read(info,Buffer,Count) \
|
|
467 |
((info)->read_pos + (Count) <= (info)->read_end ?\
|
|
468 |
(memcpy(Buffer,(info)->read_pos,(size_t) (Count)), \
|
|
469 |
((info)->read_pos+=(Count)),0) :\
|
|
470 |
(*(info)->read_function)((info),Buffer,Count))
|
|
471 |
||
472 |
#define my_b_write(info,Buffer,Count) \
|
|
473 |
((info)->write_pos + (Count) <=(info)->write_end ?\
|
|
474 |
(memcpy((info)->write_pos, (Buffer), (size_t)(Count)),\
|
|
475 |
((info)->write_pos+=(Count)),0) : \
|
|
476 |
(*(info)->write_function)((info),(Buffer),(Count)))
|
|
477 |
||
478 |
#define my_b_get(info) \
|
|
479 |
((info)->read_pos != (info)->read_end ?\
|
|
480 |
((info)->read_pos++, (int) (uchar) (info)->read_pos[-1]) :\
|
|
481 |
_my_b_get(info))
|
|
482 |
||
483 |
/* my_b_write_byte dosn't have any err-check */
|
|
484 |
#define my_b_write_byte(info,chr) \
|
|
485 |
(((info)->write_pos < (info)->write_end) ?\
|
|
486 |
((*(info)->write_pos++)=(chr)) :\
|
|
487 |
(_my_b_write(info,0,0) , ((*(info)->write_pos++)=(chr))))
|
|
488 |
||
489 |
#define my_b_fill_cache(info) \
|
|
490 |
(((info)->read_end=(info)->read_pos),(*(info)->read_function)(info,0,0))
|
|
491 |
||
492 |
#define my_b_tell(info) ((info)->pos_in_file + \
|
|
493 |
(size_t) (*(info)->current_pos - (info)->request_pos))
|
|
494 |
||
495 |
#define my_b_get_buffer_start(info) (info)->request_pos
|
|
496 |
#define my_b_get_bytes_in_buffer(info) (char*) (info)->read_end - \
|
|
497 |
(char*) my_b_get_buffer_start(info)
|
|
498 |
#define my_b_get_pos_in_file(info) (info)->pos_in_file
|
|
499 |
||
500 |
/* tell write offset in the SEQ_APPEND cache */
|
|
501 |
int my_b_copy_to_file(IO_CACHE *cache, FILE *file); |
|
502 |
my_off_t my_b_append_tell(IO_CACHE* info); |
|
503 |
my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */ |
|
504 |
||
505 |
#define my_b_bytes_in_cache(info) (size_t) (*(info)->current_end - \
|
|
506 |
*(info)->current_pos)
|
|
507 |
||
508 |
typedef uint32 ha_checksum; |
|
509 |
||
510 |
/* Define the type of function to be passed to process_default_option_files */
|
|
511 |
typedef int (*Process_option_func)(void *ctx, const char *group_name, |
|
512 |
const char *option); |
|
513 |
||
514 |
#include <my_alloc.h> |
|
515 |
||
516 |
||
517 |
/* Prototypes for mysys and my_func functions */
|
|
518 |
||
519 |
extern int my_copy(const char *from,const char *to,myf MyFlags); |
|
520 |
extern int my_append(const char *from,const char *to,myf MyFlags); |
|
521 |
extern int my_delete(const char *name,myf MyFlags); |
|
522 |
extern int my_getwd(char * buf,size_t size,myf MyFlags); |
|
523 |
extern int my_setwd(const char *dir,myf MyFlags); |
|
524 |
extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags); |
|
525 |
extern void *my_once_alloc(size_t Size,myf MyFlags); |
|
526 |
extern void my_once_free(void); |
|
527 |
extern char *my_once_strdup(const char *src,myf myflags); |
|
528 |
extern void *my_once_memdup(const void *src, size_t len, myf myflags); |
|
529 |
extern File my_open(const char *FileName,int Flags,myf MyFlags); |
|
530 |
extern File my_register_filename(File fd, const char *FileName, |
|
531 |
enum file_type type_of_file, |
|
532 |
uint error_message_number, myf MyFlags); |
|
533 |
extern File my_create(const char *FileName,int CreateFlags, |
|
534 |
int AccessFlags, myf MyFlags); |
|
535 |
extern int my_close(File Filedes,myf MyFlags); |
|
536 |
extern File my_dup(File file, myf MyFlags); |
|
537 |
extern int my_mkdir(const char *dir, int Flags, myf MyFlags); |
|
538 |
extern int my_readlink(char *to, const char *filename, myf MyFlags); |
|
539 |
extern int my_realpath(char *to, const char *filename, myf MyFlags); |
|
540 |
extern File my_create_with_symlink(const char *linkname, const char *filename, |
|
541 |
int createflags, int access_flags, |
|
542 |
myf MyFlags); |
|
543 |
extern int my_delete_with_symlink(const char *name, myf MyFlags); |
|
544 |
extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags); |
|
545 |
extern int my_symlink(const char *content, const char *linkname, myf MyFlags); |
|
546 |
extern size_t my_read(File Filedes,uchar *Buffer,size_t Count,myf MyFlags); |
|
547 |
extern int my_rename(const char *from,const char *to,myf MyFlags); |
|
548 |
extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags); |
|
549 |
extern my_off_t my_tell(File fd,myf MyFlags); |
|
550 |
extern size_t my_write(File Filedes,const uchar *Buffer,size_t Count, |
|
551 |
myf MyFlags); |
|
552 |
extern size_t my_fread(FILE *stream,uchar *Buffer,size_t Count,myf MyFlags); |
|
553 |
extern size_t my_fwrite(FILE *stream,const uchar *Buffer,size_t Count, |
|
554 |
myf MyFlags); |
|
555 |
extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags); |
|
556 |
extern my_off_t my_ftell(FILE *stream,myf MyFlags); |
|
557 |
extern void *_mymalloc(size_t uSize,const char *sFile, |
|
558 |
uint uLine, myf MyFlag); |
|
559 |
extern void *_myrealloc(void *pPtr,size_t uSize,const char *sFile, |
|
560 |
uint uLine, myf MyFlag); |
|
561 |
extern void * my_multi_malloc _VARARGS((myf MyFlags, ...)); |
|
562 |
extern void _myfree(void *pPtr,const char *sFile,uint uLine, myf MyFlag); |
|
563 |
extern int _sanity(const char *sFile, uint uLine); |
|
564 |
extern void *_my_memdup(const void *from, size_t length, |
|
565 |
const char *sFile, uint uLine,myf MyFlag); |
|
566 |
extern char * _my_strdup(const char *from, const char *sFile, uint uLine, |
|
567 |
myf MyFlag); |
|
568 |
extern char *_my_strndup(const char *from, size_t length, |
|
569 |
const char *sFile, uint uLine, |
|
570 |
myf MyFlag); |
|
571 |
||
572 |
/* implemented in my_memmem.c */
|
|
573 |
extern void *my_memmem(const void *haystack, size_t haystacklen, |
|
574 |
const void *needle, size_t needlelen); |
|
575 |
||
576 |
||
577 |
#define my_access access
|
|
578 |
extern int check_if_legal_filename(const char *path); |
|
579 |
extern int check_if_legal_tablename(const char *path); |
|
580 |
||
581 |
#define my_delete_allow_opened(fname,flags) my_delete((fname),(flags))
|
|
582 |
||
583 |
#ifndef TERMINATE
|
|
584 |
extern void TERMINATE(FILE *file, uint flag); |
|
585 |
#endif
|
|
586 |
extern void init_glob_errs(void); |
|
587 |
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags); |
|
588 |
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags); |
|
589 |
extern int my_fclose(FILE *fd,myf MyFlags); |
|
590 |
extern int my_sync(File fd, myf my_flags); |
|
591 |
extern int my_sync_dir(const char *dir_name, myf my_flags); |
|
592 |
extern int my_sync_dir_by_file(const char *file_name, myf my_flags); |
|
593 |
extern void my_error _VARARGS((int nr,myf MyFlags, ...)); |
|
594 |
extern void my_printf_error _VARARGS((uint my_err, const char *format, |
|
595 |
myf MyFlags, ...)) |
|
596 |
ATTRIBUTE_FORMAT(printf, 2, 4); |
|
597 |
extern int my_error_register(const char **errmsgs, int first, int last); |
|
598 |
extern const char **my_error_unregister(int first, int last); |
|
599 |
extern void my_message(uint my_err, const char *str,myf MyFlags); |
|
600 |
extern void my_message_no_curses(uint my_err, const char *str,myf MyFlags); |
|
601 |
extern my_bool my_init(void); |
|
602 |
extern void my_end(int infoflag); |
|
603 |
extern int my_redel(const char *from, const char *to, int MyFlags); |
|
604 |
extern int my_copystat(const char *from, const char *to, int MyFlags); |
|
605 |
extern char * my_filename(File fd); |
|
606 |
||
607 |
#ifndef THREAD
|
|
608 |
extern void dont_break(void); |
|
609 |
extern void allow_break(void); |
|
610 |
#else
|
|
611 |
#define dont_break()
|
|
612 |
#define allow_break()
|
|
613 |
#endif
|
|
614 |
||
615 |
#ifdef EXTRA_DEBUG
|
|
616 |
void my_print_open_files(void); |
|
617 |
#else
|
|
618 |
#define my_print_open_files()
|
|
619 |
#endif
|
|
620 |
||
621 |
extern my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist); |
|
622 |
extern char *my_tmpdir(MY_TMPDIR *tmpdir); |
|
623 |
extern void free_tmpdir(MY_TMPDIR *tmpdir); |
|
624 |
||
625 |
extern void my_remember_signal(int signal_number,sig_handler (*func)(int)); |
|
626 |
extern size_t dirname_part(char * to,const char *name, size_t *to_res_length); |
|
627 |
extern size_t dirname_length(const char *name); |
|
628 |
#define base_name(A) (A+dirname_length(A))
|
|
629 |
extern int test_if_hard_path(const char *dir_name); |
|
630 |
extern my_bool has_path(const char *name); |
|
631 |
extern char *convert_dirname(char *to, const char *from, const char *from_end); |
|
632 |
extern void to_unix_path(char * name); |
|
633 |
extern char * fn_ext(const char *name); |
|
634 |
extern char * fn_same(char * toname,const char *name,int flag); |
|
635 |
extern char * fn_format(char * to,const char *name,const char *dir, |
|
636 |
const char *form, uint flag); |
|
637 |
extern size_t strlength(const char *str); |
|
638 |
extern void pack_dirname(char * to,const char *from); |
|
639 |
extern size_t unpack_dirname(char * to,const char *from); |
|
640 |
extern size_t cleanup_dirname(char * to,const char *from); |
|
641 |
extern size_t system_filename(char * to,const char *from); |
|
642 |
extern size_t unpack_filename(char * to,const char *from); |
|
643 |
extern char * intern_filename(char * to,const char *from); |
|
644 |
extern char * directory_file_name(char * dst, const char *src); |
|
645 |
extern int pack_filename(char * to, const char *name, size_t max_length); |
|
646 |
extern char * my_path(char * to,const char *progname, |
|
647 |
const char *own_pathname_part); |
|
648 |
extern char * my_load_path(char * to, const char *path, |
|
649 |
const char *own_path_prefix); |
|
650 |
extern int wild_compare(const char *str,const char *wildstr, |
|
651 |
pbool str_is_pattern); |
|
652 |
extern WF_PACK *wf_comp(char * str); |
|
653 |
extern int wf_test(struct wild_file_pack *wf_pack,const char *name); |
|
654 |
extern void wf_end(struct wild_file_pack *buffer); |
|
655 |
extern size_t strip_sp(char * str); |
|
656 |
extern my_bool array_append_string_unique(const char *str, |
|
657 |
const char **array, size_t size); |
|
658 |
extern void get_date(char * to,int timeflag,time_t use_time); |
|
659 |
extern void soundex(CHARSET_INFO *, char * out_pntr, char * in_pntr, |
|
660 |
pbool remove_garbage); |
|
661 |
extern int init_record_cache(RECORD_CACHE *info,size_t cachesize,File file, |
|
662 |
size_t reclength,enum cache_type type, |
|
663 |
pbool use_async_io); |
|
664 |
extern int read_cache_record(RECORD_CACHE *info,uchar *to); |
|
665 |
extern int end_record_cache(RECORD_CACHE *info); |
|
666 |
extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos, |
|
667 |
const uchar *record,size_t length); |
|
668 |
extern int flush_write_cache(RECORD_CACHE *info); |
|
669 |
extern long my_clock(void); |
|
670 |
extern sig_handler sigtstp_handler(int signal_number); |
|
671 |
extern void handle_recived_signals(void); |
|
672 |
||
673 |
extern sig_handler my_set_alarm_variable(int signo); |
|
674 |
extern void my_string_ptr_sort(uchar *base,uint items,size_t size); |
|
675 |
extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements, |
|
676 |
size_t size_of_element,uchar *buffer[]); |
|
677 |
extern qsort_t my_qsort(void *base_ptr, size_t total_elems, size_t size, |
|
678 |
qsort_cmp cmp); |
|
679 |
extern qsort_t my_qsort2(void *base_ptr, size_t total_elems, size_t size, |
|
680 |
qsort2_cmp cmp, void *cmp_argument); |
|
681 |
extern qsort2_cmp get_ptr_compare(size_t); |
|
682 |
void my_store_ptr(uchar *buff, size_t pack_length, my_off_t pos); |
|
683 |
my_off_t my_get_ptr(uchar *ptr, size_t pack_length); |
|
684 |
extern int init_io_cache(IO_CACHE *info,File file,size_t cachesize, |
|
685 |
enum cache_type type,my_off_t seek_offset, |
|
686 |
pbool use_async_io, myf cache_myflags); |
|
687 |
extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type, |
|
688 |
my_off_t seek_offset,pbool use_async_io, |
|
689 |
pbool clear_cache); |
|
690 |
extern void setup_io_cache(IO_CACHE* info); |
|
691 |
extern int _my_b_read(IO_CACHE *info,uchar *Buffer,size_t Count); |
|
692 |
#ifdef THREAD
|
|
693 |
extern int _my_b_read_r(IO_CACHE *info,uchar *Buffer,size_t Count); |
|
694 |
extern void init_io_cache_share(IO_CACHE *read_cache, IO_CACHE_SHARE *cshare, |
|
695 |
IO_CACHE *write_cache, uint num_threads); |
|
696 |
extern void remove_io_thread(IO_CACHE *info); |
|
697 |
#endif
|
|
698 |
extern int _my_b_seq_read(IO_CACHE *info,uchar *Buffer,size_t Count); |
|
699 |
extern int _my_b_net_read(IO_CACHE *info,uchar *Buffer,size_t Count); |
|
700 |
extern int _my_b_get(IO_CACHE *info); |
|
701 |
extern int _my_b_async_read(IO_CACHE *info,uchar *Buffer,size_t Count); |
|
702 |
extern int _my_b_write(IO_CACHE *info,const uchar *Buffer,size_t Count); |
|
703 |
extern int my_b_append(IO_CACHE *info,const uchar *Buffer,size_t Count); |
|
704 |
extern int my_b_safe_write(IO_CACHE *info,const uchar *Buffer,size_t Count); |
|
705 |
||
706 |
extern int my_block_write(IO_CACHE *info, const uchar *Buffer, |
|
707 |
size_t Count, my_off_t pos); |
|
708 |
extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock); |
|
709 |
||
710 |
#define flush_io_cache(info) my_b_flush_io_cache((info),1)
|
|
711 |
||
712 |
extern int end_io_cache(IO_CACHE *info); |
|
713 |
extern size_t my_b_fill(IO_CACHE *info); |
|
714 |
extern void my_b_seek(IO_CACHE *info,my_off_t pos); |
|
715 |
extern size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length); |
|
716 |
extern my_off_t my_b_filelength(IO_CACHE *info); |
|
717 |
extern size_t my_b_printf(IO_CACHE *info, const char* fmt, ...); |
|
718 |
extern size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap); |
|
719 |
extern my_bool open_cached_file(IO_CACHE *cache,const char *dir, |
|
720 |
const char *prefix, size_t cache_size, |
|
721 |
myf cache_myflags); |
|
722 |
extern my_bool real_open_cached_file(IO_CACHE *cache); |
|
723 |
extern void close_cached_file(IO_CACHE *cache); |
|
724 |
File create_temp_file(char *to, const char *dir, const char *pfx, |
|
725 |
int mode, myf MyFlags); |
|
726 |
#define my_init_dynamic_array(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D CALLER_INFO)
|
|
727 |
#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D ORIG_CALLER_INFO)
|
|
728 |
#define my_init_dynamic_array2(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E CALLER_INFO)
|
|
729 |
#define my_init_dynamic_array2_ci(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E ORIG_CALLER_INFO)
|
|
730 |
extern my_bool init_dynamic_array2(DYNAMIC_ARRAY *array,uint element_size, |
|
731 |
void *init_buffer, uint init_alloc, |
|
732 |
uint alloc_increment |
|
733 |
CALLER_INFO_PROTO); |
|
734 |
/* init_dynamic_array() function is deprecated */
|
|
735 |
extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size, |
|
736 |
uint init_alloc,uint alloc_increment |
|
737 |
CALLER_INFO_PROTO); |
|
738 |
extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,uchar * element); |
|
739 |
extern uchar *alloc_dynamic(DYNAMIC_ARRAY *array); |
|
740 |
extern uchar *pop_dynamic(DYNAMIC_ARRAY*); |
|
741 |
extern my_bool set_dynamic(DYNAMIC_ARRAY *array,uchar * element,uint array_index); |
|
742 |
extern my_bool allocate_dynamic(DYNAMIC_ARRAY *array, uint max_elements); |
|
743 |
extern void get_dynamic(DYNAMIC_ARRAY *array,uchar * element,uint array_index); |
|
744 |
extern void delete_dynamic(DYNAMIC_ARRAY *array); |
|
745 |
extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index); |
|
746 |
extern void freeze_size(DYNAMIC_ARRAY *array); |
|
747 |
extern int get_index_dynamic(DYNAMIC_ARRAY *array, uchar * element); |
|
748 |
#define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element)
|
|
749 |
#define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
|
|
750 |
#define push_dynamic(A,B) insert_dynamic((A),(B))
|
|
751 |
#define reset_dynamic(array) ((array)->elements= 0)
|
|
752 |
#define sort_dynamic(A,cmp) my_qsort((A)->buffer, (A)->elements, (A)->size_of_element, (cmp))
|
|
753 |
||
754 |
extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str, |
|
755 |
size_t init_alloc,size_t alloc_increment); |
|
756 |
extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append); |
|
757 |
my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append, |
|
758 |
size_t length); |
|
759 |
extern my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, |
|
760 |
...);
|
|
761 |
extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str); |
|
762 |
extern my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size); |
|
763 |
extern my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n); |
|
764 |
extern void dynstr_free(DYNAMIC_STRING *str); |
|
765 |
#ifdef HAVE_MLOCK
|
|
766 |
extern void *my_malloc_lock(size_t length,myf flags); |
|
767 |
extern void my_free_lock(void *ptr,myf flags); |
|
768 |
#else
|
|
769 |
#define my_malloc_lock(A,B) my_malloc((A),(B))
|
|
770 |
#define my_free_lock(A,B) my_free((A),(B))
|
|
771 |
#endif
|
|
772 |
#define alloc_root_inited(A) ((A)->min_malloc != 0)
|
|
773 |
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
|
|
774 |
#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
|
|
775 |
extern void init_alloc_root(MEM_ROOT *mem_root, size_t block_size, |
|
776 |
size_t pre_alloc_size); |
|
777 |
extern void *alloc_root(MEM_ROOT *mem_root, size_t Size); |
|
778 |
extern void *multi_alloc_root(MEM_ROOT *mem_root, ...); |
|
779 |
extern void free_root(MEM_ROOT *root, myf MyFLAGS); |
|
780 |
extern void set_prealloc_root(MEM_ROOT *root, char *ptr); |
|
781 |
extern void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size, |
|
782 |
size_t prealloc_size); |
|
783 |
extern char *strdup_root(MEM_ROOT *root,const char *str); |
|
784 |
extern char *strmake_root(MEM_ROOT *root,const char *str,size_t len); |
|
785 |
extern void *memdup_root(MEM_ROOT *root,const void *str, size_t len); |
|
786 |
extern int get_defaults_options(int argc, char **argv, |
|
787 |
char **defaults, char **extra_defaults, |
|
788 |
char **group_suffix); |
|
789 |
extern int load_defaults(const char *conf_file, const char **groups, |
|
790 |
int *argc, char ***argv); |
|
791 |
extern int modify_defaults_file(const char *file_location, const char *option, |
|
792 |
const char *option_value, |
|
793 |
const char *section_name, int remove_option); |
|
794 |
extern int my_search_option_files(const char *conf_file, int *argc, |
|
795 |
char ***argv, uint *args_used, |
|
796 |
Process_option_func func, void *func_ctx); |
|
797 |
extern void free_defaults(char **argv); |
|
798 |
extern void my_print_default_files(const char *conf_file); |
|
799 |
extern void print_defaults(const char *conf_file, const char **groups); |
|
800 |
extern my_bool my_compress(uchar *, size_t *, size_t *); |
|
801 |
extern my_bool my_uncompress(uchar *, size_t , size_t *); |
|
802 |
extern uchar *my_compress_alloc(const uchar *packet, size_t *len, |
|
803 |
size_t *complen); |
|
804 |
extern ha_checksum my_checksum(ha_checksum crc, const uchar *mem, |
|
805 |
size_t count); |
|
806 |
extern void my_sleep(ulong m_seconds); |
|
807 |
extern ulong crc32(ulong crc, const uchar *buf, uint len); |
|
808 |
extern uint my_set_max_open_files(uint files); |
|
809 |
void my_free_open_file_info(void); |
|
810 |
||
811 |
extern time_t my_time(myf flags); |
|
812 |
extern ulonglong my_getsystime(void); |
|
813 |
extern ulonglong my_micro_time(); |
|
814 |
extern ulonglong my_micro_time_and_time(time_t *time_arg); |
|
815 |
time_t my_time_possible_from_micro(ulonglong microtime); |
|
816 |
extern my_bool my_gethwaddr(uchar *to); |
|
817 |
extern int my_getncpus(); |
|
818 |
||
819 |
#ifdef HAVE_SYS_MMAN_H
|
|
820 |
#include <sys/mman.h> |
|
821 |
||
822 |
#ifndef MAP_NOSYNC
|
|
823 |
#define MAP_NOSYNC 0
|
|
824 |
#endif
|
|
825 |
#ifndef MAP_NORESERVE
|
|
826 |
#define MAP_NORESERVE 0 /* For irix and AIX */ |
|
827 |
#endif
|
|
828 |
||
829 |
#ifdef HAVE_MMAP64
|
|
830 |
#define my_mmap(a,b,c,d,e,f) mmap64(a,b,c,d,e,f)
|
|
831 |
#else
|
|
832 |
#define my_mmap(a,b,c,d,e,f) mmap(a,b,c,d,e,f)
|
|
833 |
#endif
|
|
834 |
#define my_munmap(a,b) munmap((a),(b))
|
|
835 |
||
836 |
#else
|
|
837 |
/* not a complete set of mmap() flags, but only those that nesessary */
|
|
838 |
#define PROT_READ 1
|
|
839 |
#define PROT_WRITE 2
|
|
840 |
#define MAP_NORESERVE 0
|
|
841 |
#define MAP_SHARED 0x0001
|
|
842 |
#define MAP_PRIVATE 0x0002
|
|
843 |
#define MAP_NOSYNC 0x0800
|
|
844 |
#define MAP_FAILED ((void *)-1)
|
|
845 |
#define MS_SYNC 0x0000
|
|
846 |
||
847 |
#ifndef __NETWARE__
|
|
848 |
#define HAVE_MMAP
|
|
849 |
#endif
|
|
850 |
||
851 |
void *my_mmap(void *, size_t, int, int, int, my_off_t); |
|
852 |
int my_munmap(void *, size_t); |
|
853 |
#endif
|
|
854 |
||
855 |
/* my_getpagesize */
|
|
856 |
#ifdef HAVE_GETPAGESIZE
|
|
857 |
#define my_getpagesize() getpagesize()
|
|
858 |
#else
|
|
859 |
int my_getpagesize(void); |
|
860 |
#endif
|
|
861 |
||
862 |
/* character sets */
|
|
863 |
extern uint get_charset_number(const char *cs_name, uint cs_flags); |
|
864 |
extern uint get_collation_number(const char *name); |
|
865 |
extern const char *get_charset_name(uint cs_number); |
|
866 |
||
867 |
extern CHARSET_INFO *get_charset(uint cs_number, myf flags); |
|
868 |
extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags); |
|
869 |
extern CHARSET_INFO *get_charset_by_csname(const char *cs_name, |
|
870 |
uint cs_flags, myf my_flags); |
|
871 |
||
872 |
extern my_bool resolve_charset(const char *cs_name, |
|
873 |
CHARSET_INFO *default_cs, |
|
874 |
CHARSET_INFO **cs); |
|
875 |
extern my_bool resolve_collation(const char *cl_name, |
|
876 |
CHARSET_INFO *default_cl, |
|
877 |
CHARSET_INFO **cl); |
|
878 |
||
879 |
extern void free_charsets(void); |
|
880 |
extern char *get_charsets_dir(char *buf); |
|
881 |
extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2); |
|
882 |
extern my_bool init_compiled_charsets(myf flags); |
|
883 |
extern void add_compiled_collation(CHARSET_INFO *cs); |
|
884 |
extern size_t escape_string_for_mysql(CHARSET_INFO *charset_info, |
|
885 |
char *to, size_t to_length, |
|
886 |
const char *from, size_t length); |
|
887 |
extern size_t escape_quotes_for_mysql(CHARSET_INFO *charset_info, |
|
888 |
char *to, size_t to_length, |
|
889 |
const char *from, size_t length); |
|
890 |
||
891 |
extern void thd_increment_bytes_sent(ulong length); |
|
892 |
extern void thd_increment_bytes_received(ulong length); |
|
893 |
extern void thd_increment_net_big_packet_count(ulong length); |
|
894 |
||
895 |
C_MODE_END
|
|
896 |
#endif /* _my_sys_h */ |