Annotation of win32/sql/mysql/include/my_sys.h, revision 1.2

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

E-mail: