diff options
author | Kent Boortz <kent.boortz@sun.com> | 2010-12-28 19:57:23 +0100 |
---|---|---|
committer | Kent Boortz <kent.boortz@sun.com> | 2010-12-28 19:57:23 +0100 |
commit | 85323eda8a5823e4db1fa34dc998684b67e710b5 (patch) | |
tree | f341a98de1a200ac824d90042d01052f7156ce84 /mysys | |
parent | 086130e3c07a39f998935e374f17706c63be5ee6 (diff) | |
download | mariadb-git-85323eda8a5823e4db1fa34dc998684b67e710b5.tar.gz |
- Added/updated copyright headers
- Removed files specific to compiling on OS/2
- Removed files specific to SCO Unix packaging
- Removed "libmysqld/copyright", text is included in documentation
- Removed LaTeX headers for NDB Doxygen documentation
- Removed obsolete NDB files
- Removed "mkisofs" binaries
- Removed the "cvs2cl.pl" script
- Changed a few GPL texts to use "program" instead of "library"
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/Makefile.am | 5 | ||||
-rw-r--r-- | mysys/mf_pack.c | 2 | ||||
-rw-r--r-- | mysys/my_lib.c | 4 | ||||
-rw-r--r-- | mysys/my_os2cond.c | 162 | ||||
-rw-r--r-- | mysys/my_os2dirsrch.c | 184 | ||||
-rw-r--r-- | mysys/my_os2dirsrch.h | 88 | ||||
-rw-r--r-- | mysys/my_os2dlfcn.c | 74 | ||||
-rw-r--r-- | mysys/my_os2dlfcn.h0 | 39 | ||||
-rw-r--r-- | mysys/my_os2file64.c | 394 | ||||
-rw-r--r-- | mysys/my_os2mutex.c | 83 | ||||
-rw-r--r-- | mysys/my_os2thread.c | 128 | ||||
-rw-r--r-- | mysys/my_os2tls.c | 151 |
12 files changed, 2 insertions, 1312 deletions
diff --git a/mysys/Makefile.am b/mysys/Makefile.am index 7cb87492b40..77af5a47e99 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -21,10 +21,7 @@ INCLUDES = @ZLIB_INCLUDES@ -I$(top_builddir)/include \ pkglib_LIBRARIES = libmysys.a LDADD = libmysys.a ../dbug/libdbug.a \ ../strings/libmystrings.a -noinst_HEADERS = mysys_priv.h my_static.h \ - my_os2cond.c my_os2dirsrch.c my_os2dirsrch.h \ - my_os2dlfcn.c my_os2file64.c my_os2mutex.c \ - my_os2thread.c my_os2tls.c +noinst_HEADERS = mysys_priv.h my_static.h libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \ mf_path.c mf_loadpath.c my_file.c \ my_open.c my_create.c my_dup.c my_seek.c my_read.c \ diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c index df206f7e235..e833aeb0b06 100644 --- a/mysys/mf_pack.c +++ b/mysys/mf_pack.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_lib.c b/mysys/my_lib.c index a076a0c971d..76f27cfb645 100644 --- a/mysys/my_lib.c +++ b/mysys/my_lib.c @@ -51,10 +51,6 @@ #include <descrip.h> #endif -#ifdef OS2 -#include "my_os2dirsrch.h" -#endif - #if defined(THREAD) && defined(HAVE_READDIR_R) #define READDIR(A,B,C) ((errno=readdir_r(A,B,&C)) != 0 || !C) #else diff --git a/mysys/my_os2cond.c b/mysys/my_os2cond.c deleted file mode 100644 index f0cf91404d2..00000000000 --- a/mysys/my_os2cond.c +++ /dev/null @@ -1,162 +0,0 @@ -/* Copyright (C) Yuri Dario & 2000 MySQL AB - All the above parties has a full, independent copyright to - the following code, including the right to use the code in - any manner without any demands from the other parties. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; version 2 - of the License. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA */ - -/***************************************************************************** -** The following is a simple implementation of posix conditions -*****************************************************************************/ - -#undef SAFE_MUTEX /* Avoid safe_mutex redefinitions */ -#include "mysys_priv.h" -#if defined(THREAD) && defined(OS2) -#include <m_string.h> -#include <process.h> -#include <sys/timeb.h> - -int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) -{ - cond->waiting= 0; - /* Warp3 FP29 or Warp4 FP4 or better required */ - if (DosCreateEventSem(NULL, &cond->semaphore, 0x0800, 0)) - return ENOMEM; - return 0; -} - -int pthread_cond_destroy(pthread_cond_t *cond) -{ - for (;;) - { - APIRET rc; - if ((rc= DosCloseEventSem(cond->semaphore)) != 301) - return rc ? EINVAL : 0; - DosPostEventSem(cond->semaphore); - } -} - - -int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) -{ - int rval= 0; - cond->waiting++; - if (mutex) - pthread_mutex_unlock(mutex); - if (DosWaitEventSem(cond->semaphore, SEM_INDEFINITE_WAIT)) - rval= EINVAL; - if (mutex) - pthread_mutex_lock(mutex); - cond->waiting--; - return rval; -} - -int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, - struct timespec *abstime) -{ - struct timeb curtime; - int result; - long timeout; - int rval= 0; - - _ftime(&curtime); - timeout= ((long) (abstime->ts_sec - curtime.time) * 1000L + - (long) ((abstime->ts_nsec / 1000) - curtime.millitm) / 1000L); - if (timeout < 0) /* Some safety */ - timeout= 0L; - - cond->waiting++; - - if (mutex) - pthread_mutex_unlock(mutex); - if (DosWaitEventSem(cond->semaphore, timeout) != 0) - rval= ETIMEDOUT; - if (mutex) - pthread_mutex_lock(mutex); - - cond->waiting--; - - return rval; -} - - -int pthread_cond_signal(pthread_cond_t *cond) -{ - /* Bring the next thread off the condition queue: */ - DosPostEventSem(cond->semaphore); - return 0; -} - - -int pthread_cond_broadcast(pthread_cond_t *cond) -{ - int i; - /* Enter a loop to bring all threads off the condition queue */ - for (i= cond->waiting; i--;) - DosPostEventSem(cond->semaphore); - return 0; -} - - -int pthread_attr_init(pthread_attr_t *connect_att) -{ - connect_att->dwStackSize= 0; - connect_att->dwCreatingFlag= 0; - connect_att->priority= 0; - return 0; -} - -int pthread_attr_setstacksize(pthread_attr_t *connect_att, DWORD stack) -{ - connect_att->dwStackSize= stack; - return 0; -} - -int pthread_attr_setprio(pthread_attr_t *connect_att, int priority) -{ - connect_att->priority= priority; - return 0; -} - -int pthread_attr_destroy(pthread_attr_t *connect_att) -{ - bzero((gptr) connect_att, sizeof(*connect_att)); - return 0; -} - -/**************************************************************************** -** Fix localtime_r() to be a bit safer -****************************************************************************/ - -struct tm *localtime_r(const time_t *timep, struct tm *tmp) -{ - if (*timep == (time_t) - 1) /* This will crash win32 */ - { - bzero(tmp, sizeof(*tmp)); - } - else - { - struct tm *res= localtime(timep); - if (!res) /* Wrong date */ - { - bzero(tmp, sizeof(*tmp)); /* Keep things safe */ - return 0; - } - *tmp= *res; - } - return tmp; -} -#endif /* __WIN__ */ diff --git a/mysys/my_os2dirsrch.c b/mysys/my_os2dirsrch.c deleted file mode 100644 index 27e774c8e04..00000000000 --- a/mysys/my_os2dirsrch.c +++ /dev/null @@ -1,184 +0,0 @@ -/* Copyright (C) Yuri Dario & 2000-2003 MySQL AB - All the above parties has a full, independent copyright to - the following code, including the right to use the code in - any manner without any demands from the other parties. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; version 2 - of the License. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA */ - - -/* Win32 directory search emulation */ - -#if defined(OS2) - -long _findfirst( char* path, struct _finddata_t* dos_file) -{ - HDIR hdir = HDIR_CREATE; - APIRET rc; - FILEFINDBUF3 buf3; - ULONG entries = 1; - -#ifdef _DEBUG - printf( "_findfirst path %s\n", path); -#endif - - memset( &buf3, 0, sizeof( buf3)); - rc = DosFindFirst( - path, /* The ASCIIZ path name of the file or subdirectory to be found. */ - &hdir, /* The handle associated with this DosFindFirst request. */ - FILE_NORMAL | FILE_DIRECTORY, /* Attribute value that determines the file objects to be searched for. */ - &buf3, /* Result buffer. */ - sizeof( buf3), /* The length, in bytes, of pfindbuf. */ - &entries, /* Pointer to the number of entries: */ - FIL_STANDARD); /* The level of file information required. */ - -#ifdef _DEBUG - printf( "_findfirst rc=%d hdir=%d entries=%d->%s\n", rc, hdir, entries, - buf3.achName); -#endif - - if (rc /* && entries == 0 */) - return -1; - - if (dos_file) - { - memset( dos_file, 0, sizeof( struct _finddata_t)); - strcpy( dos_file->name, buf3.achName); - dos_file->size = buf3.cbFile; - dos_file->attrib = buf3.attrFile; - } - return (ULONG) hdir; -} - - -long _findnext( long hdir, struct _finddata_t* dos_file) -{ - APIRET rc; - FILEFINDBUF3 buf3; - ULONG entries = 1; - - memset( &buf3, 0, sizeof( buf3)); - rc = DosFindNext(hdir, - &buf3, /* Result buffer. */ - sizeof( buf3), /* Length, in bytes, of pfindbuf. */ - &entries); /* Pointer to the number of entries */ - -#ifdef _DEBUG - printf( "_findnext rc=%d hdir=%d entries=%d->%s\n", rc, hdir, entries, - buf3.achName); -#endif - - if (rc /* && entries == 0 */) - return -1; - - if (dos_file) - { - memset( dos_file, 0, sizeof( struct _finddata_t)); - strcpy( dos_file->name, buf3.achName); - dos_file->size = buf3.cbFile; - dos_file->attrib = buf3.attrFile; - } - return 0; -} - -void _findclose( long hdir) -{ - APIRET rc; - - rc = DosFindClose( hdir); -#ifdef _DEBUG - printf( "_findclose rc=%d hdir=%d\n", rc, hdir); -#endif -} - -DIR* opendir(char* path) -{ - DIR* dir = (DIR*) calloc(1, sizeof( DIR)); - char buffer[260]; - APIRET rc; - ULONG entries = 1; - - strmov(strmov(buffer, path), "*.*"); - -#ifdef _DEBUG - printf( "_findfirst path %s\n", buffer); -#endif - - dir->hdir = HDIR_CREATE; - memset( &dir->buf3, 0, sizeof( dir->buf3)); - rc = DosFindFirst( - buffer, /* Address of the ASCIIZ path name of the file or subdirectory to be found. */ - &dir->hdir, /* Address of the handle associated with this DosFindFirst request. */ - FILE_NORMAL | FILE_DIRECTORY, /* Attribute value that determines the file objects to be searched for. */ - &dir->buf3, /* Result buffer. */ - sizeof( dir->buf3), /* The length, in bytes, of pfindbuf. */ - &entries, /* Pointer to the number of entries: */ - FIL_STANDARD); /* The level of file information required. */ - -#ifdef _DEBUG - printf( "opendir rc=%d hdir=%d entries=%d->%s\n", rc, dir->hdir, entries, dir->buf3.achName); -#endif - - if (rc /* && entries == 0 */) - return NULL; - - return dir; -} - - -struct dirent* readdir( DIR* dir) -{ - APIRET rc; - ULONG entries = 1; - - if (!dir->buf3.achName[0]) /* file not found on previous query */ - return NULL; - - /* copy last file name */ - strcpy( dir->ent.d_name, dir->buf3.achName); - - /* query next file */ - memset( &dir->buf3, 0, sizeof( dir->buf3)); - rc= DosFindNext( - dir->hdir, - &dir->buf3, /* Result buffer. */ - sizeof(dir->buf3), /* Length, in bytes, of pfindbuf. */ - &entries); /* Pointer to the number of entries */ - -#ifdef _DEBUG - printf( "_findnext rc=%d hdir=%d entries=%d->%s\n", rc, dir->hdir, entries, - dir->buf3.achName); -#endif - - if (rc /* && entries == 0 */) - *dir->buf3.achName= 0; /* reset name for next query */ - - return &dir->ent; -} - - -int closedir (DIR *dir) -{ - APIRET rc; - - rc = DosFindClose( dir->hdir); -#ifdef _DEBUG - printf( "_findclose rc=%d hdir=%d\n", rc, dir->hdir); -#endif - free(dir); - return 0; -} - -#endif /* OS2 */ diff --git a/mysys/my_os2dirsrch.h b/mysys/my_os2dirsrch.h deleted file mode 100644 index e3af6740769..00000000000 --- a/mysys/my_os2dirsrch.h +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (C) Yuri Dario & 2000 MySQL AB - All the above parties has a full, independent copyright to - the following code, including the right to use the code in - any manner without any demands from the other parties. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; version 2 - of the License. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA */ - -/* Win32 directory search emulation */ - -#ifndef __MY_OS2DIRSRCH2_H__ -#define __MY_OS2DIRSRCH2_H__ - -#ifdef __cplusplus_00 -extern "C" { -#endif - -struct _finddata_t -{ - unsigned attrib; -#ifdef NOT_USED - unsigned long time_create; /* -1 for FAT file systems */ - unsigned long time_access; /* -1 for FAT file systems */ - unsigned long time_write; -#endif - unsigned long size; - char name[260]; -#ifdef NOT_USED - uint16 wr_date; - uint16 wr_time; -#endif -}; - - -struct dirent -{ -#ifdef NOT_USED - unsigned attrib; - unsigned long time_create; /* -1 for FAT file systems */ - unsigned long time_access; /* -1 for FAT file systems */ - unsigned long time_write; - unsigned long size; -#endif - char d_name[260]; -#ifdef NOT_USED - uint16 wr_date; - uint16 wr_time; -#endif -}; - -struct DIR -{ - HDIR hdir; - FILEFINDBUF3 buf3; - struct dirent ent; -}; - -DIR *opendir ( char *); -struct dirent *readdir (DIR *); -int closedir (DIR *); - -#ifdef NOT_USED -#define _A_NORMAL FILE_NORMAL -#define _A_SUBDIR FILE_DIRECTORY -#define _A_RDONLY FILE_READONLY - -long _findfirst( char*, struct _finddata_t*); -long _findnext( long, struct _finddata_t*); -void _findclose( long); -#endif - -#ifdef __cplusplus_00 -} -#endif - -#endif /* __MY_OS2DIRSRCH2_H__ */ diff --git a/mysys/my_os2dlfcn.c b/mysys/my_os2dlfcn.c deleted file mode 100644 index 74be940d0d4..00000000000 --- a/mysys/my_os2dlfcn.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright (C) Yuri Dario & 2000 MySQL AB - All the above parties has a full, independent copyright to - the following code, including the right to use the code in - any manner without any demands from the other parties. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; version 2 - of the License. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA */ - -/* - * dlfcn::Unix dynamic loading for OS/2 - * - * Compatibility layer for dynamic loading. - * Only minimal implementation - * -*/ - -#define RTLD_LAZY 0 -#define RTLD_NOW 0 - -void* dlopen( char* path, int flag); -char* dlerror( void); -void* dlsym( void* hmod, char* fn); -void dlclose( void* hmod); - -char fail[ 256]; - -void* dlopen( char* path, int flag) -{ - APIRET rc; - HMODULE hmod; - - rc = DosLoadModule( fail, sizeof( fail), path, &hmod); - if (rc) - return NULL; - - return (void*) hmod; -} - -char* dlerror( void) -{ - return fail; -} - -void* dlsym( void* hmod, char* fn) -{ - APIRET rc; - PFN addr; - - rc = DosQueryProcAddr( (HMODULE) hmod, 0l, fn, &addr); - if (rc) - return NULL; - - return (void*) addr; -} - -void dlclose( void* hmod) -{ - APIRET rc; - - rc = DosFreeModule( (HMODULE) hmod); - -} diff --git a/mysys/my_os2dlfcn.h0 b/mysys/my_os2dlfcn.h0 deleted file mode 100644 index ec05eebc47b..00000000000 --- a/mysys/my_os2dlfcn.h0 +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) Yuri Dario & 2000 MySQL AB - All the above parties has a full, independent copyright to - the following code, including the right to use the code in - any manner without any demands from the other parties. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; version 2 - of the License. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA */ -/* - * dlfcn::Unix dynamic loading for OS/2 - * - * Compatibility layer for dynamic loading. - * Only minimal implementation - * -*/ - -#ifndef __DLFCN_H__ -#define __DLFCN_H__ - -#define RTLD_LAZY 0 -#define RTLD_NOW 0 - -void* dlopen( char* path, int flag); -char* dlerror( void); -void* dlsym( void* hmod, char* fn); -void dlclose( void* hmod); - -#endif diff --git a/mysys/my_os2file64.c b/mysys/my_os2file64.c deleted file mode 100644 index 52156903b80..00000000000 --- a/mysys/my_os2file64.c +++ /dev/null @@ -1,394 +0,0 @@ -/* Copyright (C) Yuri Dario & 2000 MySQL AB - All the above parties has a full, independent copyright to - the following code, including the right to use the code in - any manner without any demands from the other parties. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; version 2 - of the License. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA */ - -void _OS2errno( APIRET rc); -longlong _lseek64( int fd, longlong offset, int seektype); -int _lock64( int fd, int locktype, my_off_t start, - my_off_t length, myf MyFlags); -int _sopen64( const char *name, int oflag, int shflag, int mask); - -/* - This class is used to define a global c++ variable, that - is initialized before main() gets called. -*/ - -class File64bit -{ - public: - File64bit(); /* default constructor */ -} initFile64bit; - -static APIRET (* APIENTRY _DosOpenL)(PCSZ pszFileName, - PHFILE phf, - PULONG pulAction, - LONGLONG cbFile, - ULONG ulAttribute, - ULONG fsOpenFlags, - ULONG fsOpenMode, - PEAOP2 peaop2); -static APIRET (* APIENTRY _DosSetFilePtrL)(HFILE hFile, - LONGLONG ib, - ULONG method, - PLONGLONG ibActual); -static APIRET (* APIENTRY _DosSetFileLocksL)(HFILE hFile, - PFILELOCKL pflUnlock, - PFILELOCKL pflLock, - ULONG timeout, - ULONG flags); - -#define EIO EINVAL -#define ESPIPE EBADSEEK - - -static unsigned char const errno_tab[] = -{ - 0 , EINVAL, ENOENT, ENOENT, EMFILE, /* 0..4 */ - EACCES, EBADF, EIO, ENOMEM, EIO, /* 5..9 */ - EINVAL, ENOEXEC,EINVAL, EINVAL, EINVAL, /* 10..14 */ - ENOENT, EBUSY, EXDEV, ENOENT, EROFS, /* 15..19 */ - EIO, EIO, EIO, EIO, EIO, /* 20..24 */ - EIO, EIO, EIO, ENOSPC, EIO, /* 25..29 */ - EIO, EIO, EACCES, EACCES, EIO, /* 30..34 */ - EIO, EIO, EIO, EIO, ENOSPC, /* 35..39 */ - EIO, EIO, EIO, EIO, EIO, /* 40..44 */ - EIO, EIO, EIO, EIO, EIO, /* 45..49 */ - EIO, EIO, EIO, EIO, EBUSY, /* 50..54 */ - EIO, EIO, EIO, EIO, EIO, /* 55..59 */ - EIO, ENOSPC, ENOSPC, EIO, EIO, /* 60..64 */ - EACCES, EIO, EIO, EIO, EIO, /* 65..69 */ - EIO, EIO, EIO, EROFS, EIO, /* 70..74 */ - EIO, EIO, EIO, EIO, EIO, /* 75..79 */ - EEXIST, EIO, ENOENT, EIO, EIO, /* 80..84 */ - EIO, EIO, EINVAL, EIO, EAGAIN, /* 85..89 */ - EIO, EIO, EIO, EIO, EIO, /* 90..94 */ - EINTR, EIO, EIO, EIO, EACCES, /* 95..99 */ - ENOMEM, EINVAL, EINVAL, ENOMEM, EINVAL, /* 100..104 */ - EINVAL, ENOMEM, EIO, EACCES, EPIPE, /* 105..109 */ - ENOENT, E2BIG, ENOSPC, ENOMEM, EBADF, /* 110..114 */ - EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 115..119 */ - EINVAL, EINVAL, EINVAL, ENOENT, EINVAL, /* 120..124 */ - ENOENT, ENOENT, ENOENT, ECHILD, ECHILD, /* 125..129 */ - EACCES, EINVAL, ESPIPE, EINVAL, EINVAL, /* 130..134 */ - EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 135..139 */ - EINVAL, EINVAL, EBUSY, EINVAL, EINVAL, /* 140..144 */ - EINVAL, EINVAL, EINVAL, EBUSY, EINVAL, /* 145..149 */ - EINVAL, EINVAL, ENOMEM, EINVAL, EINVAL, /* 150..154 */ - EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 155..159 */ - EINVAL, EINVAL, EINVAL, EINVAL, EAGAIN, /* 160..164 */ - EINVAL, EINVAL, EACCES, EINVAL, EINVAL, /* 165..169 */ - EBUSY, EINVAL, EINVAL, EINVAL, EINVAL, /* 170..174 */ - EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 175..179 */ - EINVAL, EINVAL, EINVAL, EINVAL, ECHILD, /* 180..184 */ - EINVAL, EINVAL, ENOENT, EINVAL, EINVAL, /* 185..189 */ - ENOEXEC,ENOEXEC,ENOEXEC,ENOEXEC,ENOEXEC, /* 190..194 */ - ENOEXEC,ENOEXEC,ENOEXEC,ENOEXEC,ENOEXEC, /* 195..199 */ - ENOEXEC,ENOEXEC,ENOEXEC,ENOENT, EINVAL, /* 200..204 */ - EINVAL, ENAMETOOLONG, EINVAL, EINVAL, EINVAL, /* 205..209 */ - EINVAL, EINVAL, EACCES, ENOEXEC,ENOEXEC, /* 210..214 */ - EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 215..219 */ - EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 220..224 */ - EINVAL, EINVAL, EINVAL, ECHILD, EINVAL, /* 225..229 */ - EINVAL, EBUSY, EAGAIN, ENOTCONN, EINVAL, /* 230..234 */ - EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 235..239 */ - EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 240..244 */ - EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 245..249 */ - EACCES, EACCES, EINVAL, ENOENT, EINVAL, /* 250..254 */ - EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 255..259 */ - EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 260..264 */ - EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 265..269 */ - EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 270..274 */ - EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 275..279 */ - EINVAL, EINVAL, EINVAL, EINVAL, EEXIST, /* 280..284 */ - EEXIST, EINVAL, EINVAL, EINVAL, EINVAL, /* 285..289 */ - ENOMEM, EMFILE, EINVAL, EINVAL, EINVAL, /* 290..294 */ - EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 295..299 */ - EINVAL, EBUSY, EINVAL, ESRCH, EINVAL, /* 300..304 */ - ESRCH, EINVAL, EINVAL, EINVAL, ESRCH, /* 305..309 */ - EINVAL, ENOMEM, EINVAL, EINVAL, EINVAL, /* 310..314 */ - EINVAL, E2BIG, ENOENT, EIO, EIO, /* 315..319 */ - EINVAL, EINVAL, EINVAL, EINVAL, EAGAIN, /* 320..324 */ - EINVAL, EINVAL, EINVAL, EIO, ENOENT, /* 325..329 */ - EACCES, EACCES, EACCES, ENOENT, ENOMEM /* 330..334 */ -}; - -/* - * Initialize 64bit file access: dynamic load of WSeB API -*/ - File64bit :: File64bit() -{ - HMODULE hDoscalls; - - if (DosQueryModuleHandle("DOSCALLS", &hDoscalls) != NO_ERROR) - return; - - if (DosQueryProcAddr(hDoscalls, 981, NULL, (PFN *)&_DosOpenL) != NO_ERROR) - return; - - if (DosQueryProcAddr(hDoscalls, 988, NULL, (PFN *)&_DosSetFilePtrL) != NO_ERROR) { - _DosOpenL = NULL; - return; - } - - if (DosQueryProcAddr(hDoscalls, 986, NULL, (PFN *)&_DosSetFileLocksL) != NO_ERROR) { - _DosOpenL = NULL; - _DosSetFilePtrL = NULL; - return; - } - /* notify success */ -#ifdef MYSQL_SERVER - printf( "WSeB 64bit file API loaded.\n"); -#endif -} - -void _OS2errno( APIRET rc) -{ - if (rc >= sizeof (errno_tab)) - errno = EINVAL; - else - errno = errno_tab[rc]; -} - - -longlong _lseek64( int fd, longlong offset, int seektype) -{ - APIRET rc; - longlong actual; - - if (_DosSetFilePtrL) - rc = _DosSetFilePtrL( fd, offset, seektype, &actual); - else - { - ULONG ulActual; - rc = DosSetFilePtr( fd, (long) offset, seektype, &ulActual); - actual = ulActual; - } - - if (!rc) - return( actual); /* NO_ERROR */ - - _OS2errno( rc); /* set errno */ - return(-1); /* seek failed */ -} - - -inline APIRET _SetFileLocksL(HFILE hFile, - PFILELOCKL pflUnlock, - PFILELOCKL pflLock, - ULONG timeout, - ULONG flags) -{ - if (_DosSetFileLocksL) - { - APIRET rc; - rc = _DosSetFileLocksL( hFile, pflUnlock, pflLock, timeout, flags); - - /* - on FAT/HPFS/LAN a INVALID_PARAMETER is returned, seems that - only JFS can handle >2GB ranges. - */ - if (rc != 87) - return rc; - /* got INVALID_PARAMETER, fallback to standard call */ - } - - FILELOCK flUnlock = { pflUnlock->lOffset, pflUnlock->lRange }; - FILELOCK flLock = { pflLock->lOffset, pflLock->lRange }; - return DosSetFileLocks( hFile, &flUnlock, &flLock, timeout, flags); -} - - -int _lock64( int fd, int locktype, my_off_t start, - my_off_t length, myf MyFlags) -{ - FILELOCKL LockArea = {0,0}, UnlockArea = {0,0}; - ULONG readonly = 0; - APIRET rc = -1; - - switch (locktype) { - case F_UNLCK: - UnlockArea.lOffset = start; - UnlockArea.lRange = length ? length : LONGLONG_MAX; - break; - - case F_RDLCK: - case F_WRLCK: - LockArea.lOffset = start; - LockArea.lRange = length ? length : LONGLONG_MAX; - readonly = (locktype == F_RDLCK ? 1 : 0); - break; - - default: - errno = EINVAL; - rc = -1; - break; - } - - if (MyFlags & MY_DONT_WAIT) - { - rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 0, readonly); - /* printf("fd %d, locktype %d, rc %d (dont_wait)\n", fd, locktype, rc); */ - if (rc == 33) { /* Lock Violation */ - - DBUG_PRINT("info",("Was locked, trying with timeout")); - rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 1 * 1000, readonly); - /* printf( "fd %d, locktype %d, rc %d (dont_wait with timeout)\n", fd, locktype, rc); */ - } - } - else - { - while (rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 0, readonly) && - (rc == 33)) - { - printf("."); - DosSleep(1 * 1000); - } - /* printf( "fd %d, locktype %d, rc %d (wait2)\n", fd, locktype, rc); */ - } - if (!rc) - return(0); /* NO_ERROR */ - _OS2errno( rc); /* set errno */ - return(-1); /* lock failed */ -} - - -int sopen(const char *name, int oflag, int shflag, int mask) -{ - int fail_errno; - APIRET rc = 0; - HFILE hf = 0; - ULONG ulAction = 0; - LONGLONG cbFile = 0; - ULONG ulAttribute = FILE_NORMAL; - ULONG fsOpenFlags = 0; - ULONG fsOpenMode = 0; - - /* Extract the access mode and sharing mode bits. */ - fsOpenMode = (shflag & 0xFF) | (oflag & 0x03); - - /* - Translate ERROR_OPEN_FAILED to ENOENT unless O_EXCL is set (see - below). - */ - fail_errno = ENOENT; - - /* - Compute `open_flag' depending on `flags'. Note that _SO_CREAT is - set for O_CREAT. - */ - - if (oflag & O_CREAT) - { - if (oflag & O_EXCL) - { - fsOpenFlags = OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; - fail_errno = EEXIST; - } - else if (oflag & O_TRUNC) - fsOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; - else - fsOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; - - if (mask & S_IWRITE) - ulAttribute = FILE_NORMAL; - else - ulAttribute = FILE_READONLY; - - } - else if (oflag & O_TRUNC) - fsOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW; - else - fsOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW; - - /* Try to open the file and handle errors. */ - if (_DosOpenL) - rc = _DosOpenL( name, &hf, &ulAction, cbFile, - ulAttribute, fsOpenFlags, fsOpenMode, NULL); - else - rc = DosOpen( name, &hf, &ulAction, (LONG) cbFile, - ulAttribute, fsOpenFlags, fsOpenMode, NULL); - - if (rc == ERROR_OPEN_FAILED) - { - errno = fail_errno; - return -1; - } - if (rc != 0) - { - _OS2errno( rc); /* set errno */ - return -1; - } - if (oflag & O_APPEND) - _lseek64( hf, 0L, SEEK_END); - return hf; -} - - -int read(int fd, void *buffer, unsigned int count) -{ - APIRET rc; - ULONG actual; - - rc= DosRead( fd, (PVOID) buffer, count, &actual); - - if (!rc) - return( actual); /* NO_ERROR */ - _OS2errno( rc); /* set errno */ - return(-1); /* read failed */ -} - - -int write(int fd, const void *buffer, unsigned int count) -{ - APIRET rc; - ULONG actual; - - rc = DosWrite( fd, (PVOID) buffer, count, &actual); - - if (!rc) - return( actual); /* NO_ERROR */ - _OS2errno( rc); /* set errno */ - return(-1); /* write failed */ -} - - -int close( int fd) -{ - APIRET rc; - ULONG actual; - - rc = DosClose( fd); - - if (!rc) - return( 0); /* NO_ERROR */ - _OS2errno( rc); /* set errno */ - return(-1); /* close failed */ -} - - -int open( const char *name, int oflag) -{ - return sopen( name, oflag, OPEN_SHARE_DENYNONE, S_IREAD | S_IWRITE); -} - - -int open( const char *name, int oflag, int mask) -{ - return sopen( name, oflag, OPEN_SHARE_DENYNONE, mask); -} diff --git a/mysys/my_os2mutex.c b/mysys/my_os2mutex.c deleted file mode 100644 index 5010d6e8dd5..00000000000 --- a/mysys/my_os2mutex.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * - * Modified and extended by Antony T Curtis <antony.curtis@olcs.net> - * for use with OS/2. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ -#include <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE - -int -pthread_mutex_init(pthread_mutex_t * mutex, - const pthread_mutexattr_t * mutex_attr) -{ - (void) DosCreateMutexSem(NULL,mutex,0,0); - return (0); /* Return the completion status: */ -} - - -int -pthread_mutex_destroy(pthread_mutex_t * mutex) -{ - APIRET rc; - - do - { - rc = DosCloseMutexSem(*mutex); - if (rc == 301) DosReleaseMutexSem(*mutex); - } while (rc == 301); - - *mutex = 0; - return (0); /* Return the completion status: */ -} - - -int -pthread_mutex_lock(pthread_mutex_t * mutex) -{ - APIRET rc; - - rc = DosRequestMutexSem(*mutex,SEM_INDEFINITE_WAIT); - if (rc) - return(EINVAL); - return (0); /* Return the completion status: */ -} - - -int -pthread_mutex_unlock(pthread_mutex_t * mutex) -{ - (void) DosReleaseMutexSem(*mutex); - return (0); /* Return the completion status: */ -} -#endif diff --git a/mysys/my_os2thread.c b/mysys/my_os2thread.c deleted file mode 100644 index e34fd18d596..00000000000 --- a/mysys/my_os2thread.c +++ /dev/null @@ -1,128 +0,0 @@ -/* Copyright (C) Yuri Dario & 2000 MySQL AB - All the above parties has a full, independent copyright to - the following code, including the right to use the code in - any manner without any demands from the other parties. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; version 2 - of the License. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA */ - -/***************************************************************************** -** Simulation of posix threads calls for OS/2 -*****************************************************************************/ - -#include "mysys_priv.h" -#if defined(THREAD) && defined(OS2) -#include <m_string.h> -#include <process.h> - -static pthread_mutex_t THR_LOCK_thread; - -struct pthread_map -{ - HANDLE pthreadself; - pthread_handler func; - void * param; -}; - -void win_pthread_init(void) -{ - pthread_mutex_init(&THR_LOCK_thread,NULL); -} - -/* -** We have tried to use '_beginthreadex' instead of '_beginthread' here -** but in this case the program leaks about 512 characters for each -** created thread ! -** As we want to save the created thread handler for other threads to -** use and to be returned by pthread_self() (instead of the Win32 pseudo -** handler), we have to go trough pthread_start() to catch the returned handler -** in the new thread. -*/ - -pthread_handler_t pthread_start(void *param) -{ - DBUG_ENTER("pthread_start"); - pthread_handler func=((struct pthread_map *) param)->func; - void *func_param=((struct pthread_map *) param)->param; - my_thread_init(); /* Will always succeed in windows */ - pthread_mutex_lock(&THR_LOCK_thread); /* Wait for beginthread to return */ - win_pthread_self=((struct pthread_map *) param)->pthreadself; - pthread_mutex_unlock(&THR_LOCK_thread); - free((char*) param); /* Free param from create */ - /* pthread_exit((void*) (*func)(func_param)); */ - (*func)(func_param); - DBUG_RETURN(0); -} - - -int pthread_create(pthread_t *thread_id, pthread_attr_t *attr, - pthread_handler func, void *param) -{ - HANDLE hThread; - struct pthread_map *map; - DBUG_ENTER("pthread_create"); - - if (!(map=(struct pthread_map *)malloc(sizeof(*map)))) - DBUG_RETURN(-1); - map->func=func; - map->param=param; - pthread_mutex_lock(&THR_LOCK_thread); -#ifdef __BORLANDC__ - hThread=(HANDLE)_beginthread((void(_USERENTRY *)(void *)) pthread_start, - attr->dwStackSize ? attr->dwStackSize : - 65535, (void*) map); -#elif defined( OS2) - hThread=(HANDLE)_beginthread((void( _Optlink *)(void *)) pthread_start, NULL, - attr->dwStackSize ? attr->dwStackSize : - 65535, (void*) map); -#else - hThread=(HANDLE)_beginthread((void( __cdecl *)(void *)) pthread_start, - attr->dwStackSize ? attr->dwStackSize : - 65535, (void*) map); -#endif - DBUG_PRINT("info", ("hThread=%lu",(long) hThread)); - *thread_id=map->pthreadself=hThread; - pthread_mutex_unlock(&THR_LOCK_thread); - - if (hThread == (HANDLE) -1) - { - int error=errno; - DBUG_PRINT("error", - ("Can't create thread to handle request (error %d)",error)); - DBUG_RETURN(error ? error : -1); - } -#ifdef OS2 - my_pthread_setprio(hThread, attr->priority); -#else - VOID(SetThreadPriority(hThread, attr->priority)) ; -#endif - DBUG_RETURN(0); -} - - -void pthread_exit(void *a) -{ - _endthread(); -} - -/* This is neaded to get the macro pthread_setspecific to work */ - -int win_pthread_setspecific(void *a,void *b,uint length) -{ - memcpy(a,b,length); - return 0; -} - -#endif diff --git a/mysys/my_os2tls.c b/mysys/my_os2tls.c deleted file mode 100644 index 49100c65516..00000000000 --- a/mysys/my_os2tls.c +++ /dev/null @@ -1,151 +0,0 @@ -/* Copyright (C) Yuri Dario & 2000 MySQL AB - All the above parties has a full, independent copyright to - the following code, including the right to use the code in - any manner without any demands from the other parties. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; version 2 - of the License. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA */ - -DWORD TlsAlloc( void); -BOOL TlsFree( DWORD); -PVOID TlsGetValue( DWORD); -BOOL TlsSetValue( DWORD, PVOID); - -#define TLS_MINIMUM_AVAILABLE 64 - - -PULONG tls_storage; /* TLS local storage */ -DWORD tls_bits[2]; /* TLS in-use bits */ -pthread_mutex_t tls_mutex; /* TLS mutex for in-use bits */ - - -DWORD TlsAlloc( void) -{ - DWORD index = -1; - DWORD mask, tibidx; - int i; - - if (tls_storage == NULL) - { - - APIRET rc; - - /* allocate memory for TLS storage */ - rc = DosAllocThreadLocalMemory( 1, &tls_storage); - if (rc) - fprintf( stderr, "DosAllocThreadLocalMemory error: return code = %u\n", - rc); - /* create a mutex */ - if (pthread_mutex_init( &tls_mutex, NULL)) - fprintf( stderr, "Failed to init TLS mutex\n"); - } - - pthread_mutex_lock( &tls_mutex); - - tibidx = 0; - if (tls_bits[0] == 0xFFFFFFFF) - { - if (tls_bits[1] == 0xFFFFFFFF) - { - fprintf( stderr, "tid#%d, no more TLS bits available\n", _threadid); - pthread_mutex_unlock( &tls_mutex); - return -1; - } - tibidx = 1; - } - - for (i=0; i<32; i++) - { - mask = (1 << i); - if ((tls_bits[ tibidx] & mask) == 0) - { - tls_bits[ tibidx] |= mask; - index = (tibidx*32) + i; - break; - } - } - tls_storage[index] = 0; - - pthread_mutex_unlock( &tls_mutex); - /* fprintf( stderr, "tid#%d, TlsAlloc index %d\n", _threadid, index); */ - return index; -} - -BOOL TlsFree( DWORD index) -{ - int tlsidx; - DWORD mask; - - if (index >= TLS_MINIMUM_AVAILABLE) - return NULL; - - pthread_mutex_lock( &tls_mutex); - - tlsidx = 0; - if (index > 32) - tlsidx++; - - mask = (1 << index); - if (tls_bits[ tlsidx] & mask) - { - tls_bits[tlsidx] &= ~mask; - tls_storage[index] = 0; - pthread_mutex_unlock( &tls_mutex); - return TRUE; - } - - pthread_mutex_unlock( &tls_mutex); - return FALSE; -} - - -PVOID TlsGetValue( DWORD index) -{ - if (index >= TLS_MINIMUM_AVAILABLE) - return NULL; - - /* verify if memory has been allocated for this thread */ - if (*tls_storage == NULL) - { - /* allocate memory for indexes */ - *tls_storage = (ULONG)calloc( TLS_MINIMUM_AVAILABLE, sizeof(int)); - /* fprintf(stderr, "tid#%d, tls_storage %x\n", _threadid, *tls_storage); */ - } - - ULONG* tls_array = (ULONG*) *tls_storage; - return (PVOID) tls_array[index]; -} - - -BOOL TlsSetValue( DWORD index, PVOID val) -{ - - /* verify if memory has been allocated for this thread */ - if (*tls_storage == NULL) - { - /* allocate memory for indexes */ - *tls_storage = (ULONG)calloc( TLS_MINIMUM_AVAILABLE, sizeof(int)); - /* fprintf(stderr, "tid#%d, tls_storage %x\n", _threadid, *tls_storage); */ - } - - if (index >= TLS_MINIMUM_AVAILABLE) - return FALSE; - - ULONG* tls_array = (ULONG*) *tls_storage; - /* fprintf( stderr, "tid#%d, TlsSetValue array %08x index %d -> %08x (old)\n", _threadid, tls_array, index, tls_array[ index]); */ - tls_array[ index] = (ULONG) val; - /* fprintf( stderr, "tid#%d, TlsSetValue array %08x index %d -> %08x\n", _threadid, tls_array, index, val); */ - return TRUE; -} |