1
/* - mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 MySQL
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; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#ifndef DRIZZLED_INTERNAL_MY_SYS_H
22
#define DRIZZLED_INTERNAL_MY_SYS_H
1
/* Copyright (C) 2000-2003 MySQL AB
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.
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.
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 */
21
#include <sys/asynch.h> /* Used by record-cache */
22
typedef struct my_aio_result {
32
#include "drizzled/internal/my_pthread.h"
34
#include "drizzled/charset_info.h" /* for CHARSET_INFO */
29
#define my_errno (errno)
31
#include <mysys/my_pthread.h>
33
#include <mystrings/m_ctype.h> /* for CHARSET_INFO */
35
34
#include <stdarg.h>
36
#include "drizzled/typelib.h"
37
#include "drizzled/internal/aio_result.h"
39
#include "drizzled/memory/root.h"
40
#include "drizzled/error.h"
42
#ifndef errno /* did we already get it? */
43
#ifdef HAVE_ERRNO_AS_DEFINE
44
#include <errno.h> /* errno is a define */
46
extern int errno; /* declare errno */
48
#endif /* #ifndef errno */
50
#include <drizzled/dynamic_array.h>
52
#ifdef HAVE_SYS_MMAN_H
56
#include "drizzled/qsort_cmp.h"
67
#define MAP_NORESERVE 0 /* For irix and AIX */
71
EDQUOT is used only in 3 C files only in mysys/. If it does not exist on
72
system, we set it to some value which can never happen.
78
/* Sun Studio does not inject this into main namespace yet */
79
#if defined(__cplusplus)
83
#define MY_INIT(name); { ::drizzled::internal::my_progname= name; ::drizzled::internal::my_init(); }
35
#include <mysys/typelib.h>
37
#define MY_INIT(name); { my_progname= name; my_init(); }
39
#define ERRMSGSIZE (SC_MAXWIDTH) /* Max length of a error message */
40
#define NRERRBUFFS (2) /* Buffers for parameters */
41
#define MY_FILE_ERROR ((size_t) -1)
86
43
/* General bitmaps for my_func's */
87
44
#define MY_FFNF 1 /* Fatal if file not found */
202
247
enum cache_type type;
252
UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN,
253
FILE_BY_MKSTEMP, FILE_BY_DUP
256
struct st_my_file_info
260
#if !defined(HAVE_PREAD)
261
pthread_mutex_t mutex;
265
extern struct st_my_file_info *my_file_info;
267
typedef struct st_dynamic_array
270
uint elements,max_element;
271
uint alloc_increment;
272
uint size_of_element;
275
typedef struct st_my_tmpdir
277
DYNAMIC_ARRAY full_list;
280
pthread_mutex_t mutex;
283
typedef struct st_dynamic_string
286
size_t length,max_length,alloc_increment;
290
typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*);
292
typedef struct st_io_cache_share
294
pthread_mutex_t mutex; /* To sync on reads into buffer. */
295
pthread_cond_t cond; /* To wait for signals. */
296
pthread_cond_t cond_writer; /* For a synchronized writer. */
297
/* Offset in file corresponding to the first byte of buffer. */
298
my_off_t pos_in_file;
299
/* If a synchronized write cache is the source of the data. */
300
struct st_io_cache *source_cache;
301
uchar *buffer; /* The read buffer. */
302
uchar *read_end; /* Behind last valid byte of buffer. */
303
int running_threads; /* threads not in lock. */
304
int total_threads; /* threads sharing the cache. */
305
int error; /* Last error. */
306
#ifdef NOT_YET_IMPLEMENTED
307
/* whether the structure should be free'd */
312
typedef struct st_io_cache /* Used when cacheing files */
314
/* Offset in file corresponding to the first byte of uchar* buffer. */
315
my_off_t pos_in_file;
317
The offset of end of file for READ_CACHE and WRITE_CACHE.
318
For SEQ_READ_APPEND it the maximum of the actual end of file and
319
the position represented by read_end.
321
my_off_t end_of_file;
322
/* Points to current read position in the buffer */
324
/* the non-inclusive boundary in the buffer for the currently valid read */
326
uchar *buffer; /* The read buffer */
327
/* Used in ASYNC_IO */
330
/* Only used in WRITE caches and in SEQ_READ_APPEND to buffer writes */
333
Only used in SEQ_READ_APPEND, and points to the current read position
334
in the write buffer. Note that reads in SEQ_READ_APPEND caches can
335
happen from both read buffer (uchar* buffer) and write buffer
336
(uchar* write_buffer).
338
uchar *append_read_pos;
339
/* Points to current write position in the write buffer */
341
/* The non-inclusive boundary of the valid write area */
345
Current_pos and current_end are convenience variables used by
346
my_b_tell() and other routines that need to know the current offset
347
current_pos points to &write_pos, and current_end to &write_end in a
348
WRITE_CACHE, and &read_pos and &read_end respectively otherwise
350
uchar **current_pos, **current_end;
352
The lock is for append buffer used in SEQ_READ_APPEND cache
353
need mutex copying from append buffer to read buffer.
355
pthread_mutex_t append_buffer_lock;
357
The following is used when several threads are reading the
358
same file in parallel. They are synchronized on disk
359
accesses reading the cached part of the file asynchronously.
360
It should be set to NULL to disable the feature. Only
361
READ_CACHE mode is supported.
363
IO_CACHE_SHARE *share;
365
A caller will use my_b_read() macro to read from the cache
366
if the data is already in cache, it will be simply copied with
367
memcpy() and internal variables will be accordinging updated with
368
no functions invoked. However, if the data is not fully in the cache,
369
my_b_read() will call read_function to fetch the data. read_function
370
must never be invoked directly.
372
int (*read_function)(struct st_io_cache *,uchar *,size_t);
374
Same idea as in the case of read_function, except my_b_write() needs to
375
be replaced with my_b_append() for a SEQ_READ_APPEND cache
377
int (*write_function)(struct st_io_cache *,const uchar *,size_t);
379
Specifies the type of the cache. Depending on the type of the cache
380
certain operations might not be available and yield unpredicatable
381
results. Details to be documented later
383
enum cache_type type;
385
Callbacks when the actual read I/O happens. These were added and
386
are currently used for binary logging of LOAD DATA INFILE - when a
387
block is read from the file, we create a block create/append event, and
388
when IO_CACHE is closed, we create an end event. These functions could,
389
of course be used for other things
391
IO_CACHE_CALLBACK pre_read;
392
IO_CACHE_CALLBACK post_read;
393
IO_CACHE_CALLBACK pre_close;
395
Counts the number of times, when we were forced to use disk. We use it to
396
increase the binlog_cache_disk_use status variable.
399
void* arg; /* for use by pre/post_read */
400
char *file_name; /* if used with 'open_cached_file' */
402
File file; /* file descriptor */
404
seek_not_done is set by my_b_seek() to inform the upcoming read/write
405
operation that a seek needs to be preformed prior to the actual I/O
406
error is 0 if the cache operation was successful, -1 if there was a
407
"hard" error, and the actual number of I/O-ed bytes if the read/write was
410
int seek_not_done,error;
411
/* buffer_length is memory size allocated for buffer or write_buffer */
412
size_t buffer_length;
413
/* read_length is the same as buffer_length except when we use async io */
415
myf myflags; /* Flags used to my_read/my_write */
417
alloced_buffer is 1 if the buffer was allocated by init_io_cache() and
418
0 if it was supplied by the user.
419
Currently READ_NET is the only one that will use a buffer allocated
425
As inidicated by ifdef, this is for async I/O, which is not currently
426
used (because it's not reliable on all systems)
429
my_off_t aio_read_pos;
430
my_aio_result aio_result;
434
typedef int (*qsort2_cmp)(const void *, const void *, const void *);
206
436
/* defines for mf_iocache */
239
488
typedef int (*Process_option_func)(void *ctx, const char *group_name,
240
489
const char *option);
242
int handle_default_option(void *in_ctx, const char *group_name,
491
#include <mysys/my_alloc.h>
247
494
/* Prototypes for mysys and my_func functions */
249
496
extern int my_copy(const char *from,const char *to,myf MyFlags);
497
extern int my_append(const char *from,const char *to,myf MyFlags);
250
498
extern int my_delete(const char *name,myf MyFlags);
251
extern int my_open(const char *FileName,int Flags,myf MyFlags);
252
extern int my_register_filename(int fd, const char *FileName,
253
uint32_t error_message_number, myf MyFlags);
254
extern int my_create(const char *FileName,int CreateFlags,
499
extern int my_getwd(char * buf,size_t size,myf MyFlags);
500
extern int my_setwd(const char *dir,myf MyFlags);
501
extern void *my_once_alloc(size_t Size,myf MyFlags);
502
extern void my_once_free(void);
503
extern char *my_once_strdup(const char *src,myf myflags);
504
extern void *my_once_memdup(const void *src, size_t len, myf myflags);
505
extern File my_open(const char *FileName,int Flags,myf MyFlags);
506
extern File my_register_filename(File fd, const char *FileName,
507
enum file_type type_of_file,
508
uint error_message_number, myf MyFlags);
509
extern File my_create(const char *FileName,int CreateFlags,
255
510
int AccessFlags, myf MyFlags);
256
extern int my_close(int Filedes,myf MyFlags);
511
extern int my_close(File Filedes,myf MyFlags);
512
extern File my_dup(File file, myf MyFlags);
257
513
extern int my_mkdir(const char *dir, int Flags, myf MyFlags);
514
extern int my_readlink(char *to, const char *filename, myf MyFlags);
258
515
extern int my_realpath(char *to, const char *filename, myf MyFlags);
259
extern int my_create_with_symlink(const char *linkname, const char *filename,
516
extern File my_create_with_symlink(const char *linkname, const char *filename,
260
517
int createflags, int access_flags,
262
519
extern int my_delete_with_symlink(const char *name, myf MyFlags);
263
520
extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags);
264
extern size_t my_read(int Filedes,unsigned char *Buffer,size_t Count,myf MyFlags);
521
extern int my_symlink(const char *content, const char *linkname, myf MyFlags);
522
extern size_t my_read(File Filedes,uchar *Buffer,size_t Count,myf MyFlags);
265
523
extern int my_rename(const char *from,const char *to,myf MyFlags);
266
extern size_t my_write(int Filedes,const unsigned char *Buffer,size_t Count,
524
extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags);
525
extern my_off_t my_tell(File fd,myf MyFlags);
526
extern size_t my_write(File Filedes,const uchar *Buffer,size_t Count,
268
extern int _sanity(const char *sFile, uint32_t uLine);
528
extern size_t my_fread(FILE *stream,uchar *Buffer,size_t Count,myf MyFlags);
529
extern size_t my_fwrite(FILE *stream,const uchar *Buffer,size_t Count,
531
extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
532
extern my_off_t my_ftell(FILE *stream,myf MyFlags);
533
extern void *_mymalloc(size_t uSize,const char *sFile,
534
uint uLine, myf MyFlag);
535
extern void *_myrealloc(void *pPtr,size_t uSize,const char *sFile,
536
uint uLine, myf MyFlag);
537
extern void * my_multi_malloc _VARARGS((myf MyFlags, ...));
538
extern void _myfree(void *pPtr,const char *sFile,uint uLine, myf MyFlag);
539
extern int _sanity(const char *sFile, uint uLine);
540
extern void *_my_memdup(const void *from, size_t length,
541
const char *sFile, uint uLine,myf MyFlag);
542
extern char * _my_strdup(const char *from, const char *sFile, uint uLine,
544
extern char *_my_strndup(const char *from, size_t length,
545
const char *sFile, uint uLine,
548
/* implemented in my_memmem.c */
549
extern void *my_memmem(const void *haystack, size_t haystacklen,
550
const void *needle, size_t needlelen);
553
#define my_access access
270
554
extern int check_if_legal_filename(const char *path);
271
555
extern int check_if_legal_tablename(const char *path);
273
557
#define my_delete_allow_opened(fname,flags) my_delete((fname),(flags))
275
extern int my_sync(int fd, myf my_flags);
560
extern void TERMINATE(FILE *file, uint flag);
562
extern void init_glob_errs(void);
563
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
564
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
565
extern int my_fclose(FILE *fd,myf MyFlags);
566
extern int my_sync(File fd, myf my_flags);
276
567
extern int my_sync_dir(const char *dir_name, myf my_flags);
277
568
extern int my_sync_dir_by_file(const char *file_name, myf my_flags);
569
extern void my_error _VARARGS((int nr,myf MyFlags, ...));
570
extern void my_printf_error _VARARGS((uint my_err, const char *format,
572
__attribute__((format(printf, 2, 4)));
573
extern int my_error_register(const char **errmsgs, int first, int last);
574
extern const char **my_error_unregister(int first, int last);
575
extern void my_message(uint my_err, const char *str,myf MyFlags);
576
extern void my_message_no_curses(uint my_err, const char *str,myf MyFlags);
278
577
extern bool my_init(void);
279
extern void my_end(void);
578
extern void my_end(int infoflag);
280
579
extern int my_redel(const char *from, const char *to, int MyFlags);
281
580
extern int my_copystat(const char *from, const char *to, int MyFlags);
282
extern char * my_filename(int fd);
284
extern void my_remember_signal(int signal_number,void (*func)(int));
581
extern char * my_filename(File fd);
584
void my_print_open_files(void);
586
#define my_print_open_files()
589
extern bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist);
590
extern char *my_tmpdir(MY_TMPDIR *tmpdir);
591
extern void free_tmpdir(MY_TMPDIR *tmpdir);
593
extern void my_remember_signal(int signal_number,sig_handler (*func)(int));
285
594
extern size_t dirname_part(char * to,const char *name, size_t *to_res_length);
286
595
extern size_t dirname_length(const char *name);
287
596
#define base_name(A) (A+dirname_length(A))
288
bool test_if_hard_path(const char *dir_name);
597
extern int test_if_hard_path(const char *dir_name);
598
extern bool has_path(const char *name);
290
599
extern char *convert_dirname(char *to, const char *from, const char *from_end);
600
extern void to_unix_path(char * name);
291
601
extern char * fn_ext(const char *name);
292
602
extern char * fn_same(char * toname,const char *name,int flag);
293
603
extern char * fn_format(char * to,const char *name,const char *dir,
294
const char *form, uint32_t flag);
604
const char *form, uint flag);
295
605
extern size_t strlength(const char *str);
606
extern void pack_dirname(char * to,const char *from);
296
607
extern size_t unpack_dirname(char * to,const char *from);
608
extern size_t cleanup_dirname(char * to,const char *from);
609
extern size_t system_filename(char * to,const char *from);
297
610
extern size_t unpack_filename(char * to,const char *from);
298
611
extern char * intern_filename(char * to,const char *from);
612
extern char * directory_file_name(char * dst, const char *src);
299
613
extern int pack_filename(char * to, const char *name, size_t max_length);
614
extern char * my_path(char * to,const char *progname,
615
const char *own_pathname_part);
300
616
extern char * my_load_path(char * to, const char *path,
301
617
const char *own_path_prefix);
302
618
extern int wild_compare(const char *str,const char *wildstr,
304
620
extern WF_PACK *wf_comp(char * str);
305
621
extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
306
622
extern void wf_end(struct wild_file_pack *buffer);
623
extern size_t strip_sp(char * str);
307
624
extern bool array_append_string_unique(const char *str,
308
625
const char **array, size_t size);
309
626
extern void get_date(char * to,int timeflag,time_t use_time);
310
extern int init_record_cache(RECORD_CACHE *info,size_t cachesize,int file,
627
extern void soundex(CHARSET_INFO *, char * out_pntr, char * in_pntr,
628
bool remove_garbage);
629
extern int init_record_cache(RECORD_CACHE *info,size_t cachesize,File file,
311
630
size_t reclength,enum cache_type type,
312
631
bool use_async_io);
313
extern int read_cache_record(RECORD_CACHE *info,unsigned char *to);
632
extern int read_cache_record(RECORD_CACHE *info,uchar *to);
314
633
extern int end_record_cache(RECORD_CACHE *info);
315
634
extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos,
316
const unsigned char *record,size_t length);
635
const uchar *record,size_t length);
317
636
extern int flush_write_cache(RECORD_CACHE *info);
318
extern void sigtstp_handler(int signal_number);
637
extern long my_clock(void);
638
extern sig_handler sigtstp_handler(int signal_number);
319
639
extern void handle_recived_signals(void);
321
extern void my_set_alarm_variable(int signo);
322
extern void my_string_ptr_sort(unsigned char *base,uint32_t items,size_t size);
323
extern void radixsort_for_str_ptr(unsigned char* base[], uint32_t number_of_elements,
324
size_t size_of_element,unsigned char *buffer[]);
325
extern void my_qsort(void *base_ptr, size_t total_elems, size_t size,
327
extern void my_qsort2(void *base_ptr, size_t total_elems, size_t size,
328
qsort2_cmp cmp, void *cmp_argument);
641
extern sig_handler my_set_alarm_variable(int signo);
642
extern void my_string_ptr_sort(uchar *base,uint items,size_t size);
643
extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
644
size_t size_of_element,uchar *buffer[]);
645
extern qsort_t my_qsort(void *base_ptr, size_t total_elems, size_t size,
647
extern qsort_t my_qsort2(void *base_ptr, size_t total_elems, size_t size,
648
qsort2_cmp cmp, void *cmp_argument);
329
649
extern qsort2_cmp get_ptr_compare(size_t);
330
void my_store_ptr(unsigned char *buff, size_t pack_length, my_off_t pos);
331
my_off_t my_get_ptr(unsigned char *ptr, size_t pack_length);
332
int create_temp_file(char *to, const char *dir, const char *pfx, myf MyFlags);
650
void my_store_ptr(uchar *buff, size_t pack_length, my_off_t pos);
651
my_off_t my_get_ptr(uchar *ptr, size_t pack_length);
652
extern int init_io_cache(IO_CACHE *info,File file,size_t cachesize,
653
enum cache_type type,my_off_t seek_offset,
654
bool use_async_io, myf cache_myflags);
655
extern bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
656
my_off_t seek_offset,bool use_async_io,
658
extern void setup_io_cache(IO_CACHE* info);
659
extern int _my_b_read(IO_CACHE *info,uchar *Buffer,size_t Count);
660
extern int _my_b_read_r(IO_CACHE *info,uchar *Buffer,size_t Count);
661
extern void init_io_cache_share(IO_CACHE *read_cache, IO_CACHE_SHARE *cshare,
662
IO_CACHE *write_cache, uint num_threads);
663
extern void remove_io_thread(IO_CACHE *info);
664
extern int _my_b_seq_read(IO_CACHE *info,uchar *Buffer,size_t Count);
665
extern int _my_b_net_read(IO_CACHE *info,uchar *Buffer,size_t Count);
666
extern int _my_b_get(IO_CACHE *info);
667
extern int _my_b_async_read(IO_CACHE *info,uchar *Buffer,size_t Count);
668
extern int _my_b_write(IO_CACHE *info,const uchar *Buffer,size_t Count);
669
extern int my_b_append(IO_CACHE *info,const uchar *Buffer,size_t Count);
670
extern int my_b_safe_write(IO_CACHE *info,const uchar *Buffer,size_t Count);
672
extern int my_block_write(IO_CACHE *info, const uchar *Buffer,
673
size_t Count, my_off_t pos);
674
extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock);
676
#define flush_io_cache(info) my_b_flush_io_cache((info),1)
678
extern int end_io_cache(IO_CACHE *info);
679
extern size_t my_b_fill(IO_CACHE *info);
680
extern void my_b_seek(IO_CACHE *info,my_off_t pos);
681
extern size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length);
682
extern my_off_t my_b_filelength(IO_CACHE *info);
683
extern size_t my_b_printf(IO_CACHE *info, const char* fmt, ...);
684
extern size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
685
extern bool open_cached_file(IO_CACHE *cache,const char *dir,
686
const char *prefix, size_t cache_size,
688
extern bool real_open_cached_file(IO_CACHE *cache);
689
extern void close_cached_file(IO_CACHE *cache);
690
File create_temp_file(char *to, const char *dir, const char *pfx,
691
int mode, myf MyFlags);
692
#define my_init_dynamic_array(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D CALLER_INFO)
693
#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D ORIG_CALLER_INFO)
694
#define my_init_dynamic_array2(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E CALLER_INFO)
695
#define my_init_dynamic_array2_ci(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E ORIG_CALLER_INFO)
696
extern bool init_dynamic_array2(DYNAMIC_ARRAY *array,uint element_size,
697
void *init_buffer, uint init_alloc,
700
/* init_dynamic_array() function is deprecated */
701
extern bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size,
702
uint init_alloc,uint alloc_increment
704
extern bool insert_dynamic(DYNAMIC_ARRAY *array,uchar * element);
705
extern uchar *alloc_dynamic(DYNAMIC_ARRAY *array);
706
extern uchar *pop_dynamic(DYNAMIC_ARRAY*);
707
extern bool set_dynamic(DYNAMIC_ARRAY *array,uchar * element,uint array_index);
708
extern bool allocate_dynamic(DYNAMIC_ARRAY *array, uint max_elements);
709
extern void get_dynamic(DYNAMIC_ARRAY *array,uchar * element,uint array_index);
710
extern void delete_dynamic(DYNAMIC_ARRAY *array);
711
extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index);
712
extern void freeze_size(DYNAMIC_ARRAY *array);
713
extern int get_index_dynamic(DYNAMIC_ARRAY *array, uchar * element);
714
#define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element)
715
#define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
716
#define push_dynamic(A,B) insert_dynamic((A),(B))
717
#define reset_dynamic(array) ((array)->elements= 0)
718
#define sort_dynamic(A,cmp) my_qsort((A)->buffer, (A)->elements, (A)->size_of_element, (cmp))
720
extern bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
721
size_t init_alloc,size_t alloc_increment);
722
extern bool dynstr_append(DYNAMIC_STRING *str, const char *append);
723
bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
725
extern bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append,
727
extern bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
728
extern bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size);
729
extern bool dynstr_trunc(DYNAMIC_STRING *str, size_t n);
730
extern void dynstr_free(DYNAMIC_STRING *str);
732
extern void *my_malloc_lock(size_t length,myf flags);
733
extern void my_free_lock(void *ptr,myf flags);
735
#define my_malloc_lock(A,B) my_malloc((A),(B))
736
#define my_free_lock(A,B) my_free((A),(B))
738
#define alloc_root_inited(A) ((A)->min_malloc != 0)
739
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
740
#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
741
extern void init_alloc_root(MEM_ROOT *mem_root, size_t block_size,
742
size_t pre_alloc_size);
743
extern void *alloc_root(MEM_ROOT *mem_root, size_t Size);
744
extern void *multi_alloc_root(MEM_ROOT *mem_root, ...);
745
extern void free_root(MEM_ROOT *root, myf MyFLAGS);
746
extern void set_prealloc_root(MEM_ROOT *root, char *ptr);
747
extern void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
748
size_t prealloc_size);
749
extern char *strdup_root(MEM_ROOT *root,const char *str);
750
extern char *strmake_root(MEM_ROOT *root,const char *str,size_t len);
751
extern void *memdup_root(MEM_ROOT *root,const void *str, size_t len);
334
752
extern int get_defaults_options(int argc, char **argv,
335
753
char **defaults, char **extra_defaults,
336
754
char **group_suffix);
337
755
extern int load_defaults(const char *conf_file, const char **groups,
338
756
int *argc, char ***argv);
757
extern int modify_defaults_file(const char *file_location, const char *option,
758
const char *option_value,
759
const char *section_name, int remove_option);
339
760
extern int my_search_option_files(const char *conf_file, int *argc,
340
char ***argv, uint32_t *args_used,
761
char ***argv, uint *args_used,
341
762
Process_option_func func, void *func_ctx);
342
763
extern void free_defaults(char **argv);
343
764
extern void my_print_default_files(const char *conf_file);
344
765
extern void print_defaults(const char *conf_file, const char **groups);
345
extern ha_checksum my_checksum(ha_checksum crc, const unsigned char *mem,
766
extern bool my_compress(uchar *, size_t *, size_t *);
767
extern bool my_uncompress(uchar *, size_t , size_t *);
768
extern uchar *my_compress_alloc(const uchar *packet, size_t *len,
770
extern ha_checksum my_checksum(ha_checksum crc, const uchar *mem,
347
extern void my_sleep(uint32_t m_seconds);
351
extern void thd_increment_bytes_sent(uint32_t length);
352
extern void thd_increment_bytes_received(uint32_t length);
353
extern void thd_increment_net_big_packet_count(uint32_t length);
355
} /* namespace internal */
356
} /* namespace drizzled */
358
#endif /* DRIZZLED_INTERNAL_MY_SYS_H */
772
extern void my_sleep(ulong m_seconds);
773
extern uint my_set_max_open_files(uint files);
774
void my_free_open_file_info(void);
776
extern time_t my_time(myf flags);
777
extern uint64_t my_getsystime(void);
778
extern uint64_t my_micro_time(void);
779
extern uint64_t my_micro_time_and_time(time_t *time_arg);
780
time_t my_time_possible_from_micro(uint64_t microtime);
781
extern bool my_gethwaddr(uchar *to);
782
extern int my_getncpus(void);
784
#ifdef HAVE_SYS_MMAN_H
785
#include <sys/mman.h>
790
#ifndef MAP_NORESERVE
791
#define MAP_NORESERVE 0 /* For irix and AIX */
795
#define my_mmap(a,b,c,d,e,f) mmap64(a,b,c,d,e,f)
797
#define my_mmap(a,b,c,d,e,f) mmap(a,b,c,d,e,f)
799
#define my_munmap(a,b) munmap((a),(b))
802
/* not a complete set of mmap() flags, but only those that nesessary */
805
#define MAP_NORESERVE 0
806
#define MAP_SHARED 0x0001
807
#define MAP_PRIVATE 0x0002
808
#define MAP_NOSYNC 0x0800
809
#define MAP_FAILED ((void *)-1)
810
#define MS_SYNC 0x0000
813
void *my_mmap(void *, size_t, int, int, int, my_off_t);
814
int my_munmap(void *, size_t);
818
#ifdef HAVE_GETPAGESIZE
819
#define my_getpagesize() getpagesize()
821
int my_getpagesize(void);
825
extern uint get_charset_number(const char *cs_name, uint cs_flags);
826
extern uint get_collation_number(const char *name);
827
extern const char *get_charset_name(uint cs_number);
829
extern CHARSET_INFO *get_charset(uint cs_number, myf flags);
830
extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
831
extern CHARSET_INFO *get_charset_by_csname(const char *cs_name,
832
uint cs_flags, myf my_flags);
834
extern bool resolve_charset(const char *cs_name,
835
CHARSET_INFO *default_cs,
837
extern bool resolve_collation(const char *cl_name,
838
CHARSET_INFO *default_cl,
841
extern void free_charsets(void);
842
extern char *get_charsets_dir(char *buf);
843
extern bool my_charset_same(const CHARSET_INFO *cs1, const CHARSET_INFO *cs2);
844
extern bool init_compiled_charsets(myf flags);
845
extern void add_compiled_collation(CHARSET_INFO *cs);
846
extern size_t escape_string_for_drizzle(const CHARSET_INFO *charset_info,
847
char *to, size_t to_length,
848
const char *from, size_t length);
849
extern size_t escape_quotes_for_drizzle(const CHARSET_INFO *charset_info,
850
char *to, size_t to_length,
851
const char *from, size_t length);
853
extern void thd_increment_bytes_sent(ulong length);
854
extern void thd_increment_bytes_received(ulong length);
855
extern void thd_increment_net_big_packet_count(ulong length);
858
#endif /* _my_sys_h */