summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
Diffstat (limited to 'mysys')
-rw-r--r--mysys/charset.c16
-rw-r--r--mysys/default.c4
-rw-r--r--mysys/getopt.c4
-rw-r--r--mysys/getopt1.c2
-rw-r--r--mysys/list.c8
-rw-r--r--mysys/mf_dirname.c2
-rw-r--r--mysys/mf_format.c2
-rw-r--r--mysys/mf_path.c2
-rw-r--r--mysys/mf_qsort.c4
-rw-r--r--mysys/mf_tempfile.c17
-rw-r--r--mysys/my_clock.c4
-rw-r--r--mysys/my_copy.c2
-rw-r--r--mysys/my_create.c4
-rw-r--r--mysys/my_getwd.c14
-rw-r--r--mysys/my_init.c2
-rw-r--r--mysys/my_lib.c15
-rw-r--r--mysys/my_lock.c58
-rw-r--r--mysys/my_malloc.c2
-rw-r--r--mysys/my_mkdir.c4
-rw-r--r--mysys/my_open.c4
-rw-r--r--mysys/my_os2cond.c188
-rw-r--r--mysys/my_os2dirsrch.c182
-rw-r--r--mysys/my_os2dirsrch.h77
-rw-r--r--mysys/my_os2dlfcn.c74
-rw-r--r--mysys/my_os2dlfcn.h039
-rw-r--r--mysys/my_os2file64.c341
-rw-r--r--mysys/my_os2mutex.c98
-rw-r--r--mysys/my_os2thread.c126
-rw-r--r--mysys/my_os2tls.c144
-rw-r--r--mysys/my_pthread.c2
-rw-r--r--mysys/my_realloc.c2
-rw-r--r--mysys/my_redel.c2
-rw-r--r--mysys/my_static.c2
-rw-r--r--mysys/my_tempnam.c17
-rw-r--r--mysys/my_thr_init.c6
-rw-r--r--mysys/my_write.c40
-rw-r--r--mysys/test_charset.c2
-rw-r--r--mysys/thr_alarm.c14
-rw-r--r--mysys/tree.c2
39 files changed, 1415 insertions, 113 deletions
diff --git a/mysys/charset.c b/mysys/charset.c
index c17c6113b57..f778afb4144 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -393,16 +393,16 @@ CHARSET_INFO *get_charset(uint cs_number, myf flags)
my_bool set_default_charset(uint cs, myf flags)
{
- CHARSET_INFO *new;
+ CHARSET_INFO *new_charset;
DBUG_ENTER("set_default_charset");
DBUG_PRINT("enter",("character set: %d",(int) cs));
- new = get_charset(cs, flags);
- if (!new)
+ new_charset = get_charset(cs, flags);
+ if (!new_charset)
{
DBUG_PRINT("error",("Couldn't set default character set"));
DBUG_RETURN(TRUE); /* error */
}
- default_charset_info = new;
+ default_charset_info = new_charset;
DBUG_RETURN(FALSE);
}
@@ -424,17 +424,17 @@ CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags)
my_bool set_default_charset_by_name(const char *cs_name, myf flags)
{
- CHARSET_INFO *new;
+ CHARSET_INFO *new_charset;
DBUG_ENTER("set_default_charset_by_name");
DBUG_PRINT("enter",("character set: %s", cs_name));
- new = get_charset_by_name(cs_name, flags);
- if (!new)
+ new_charset = get_charset_by_name(cs_name, flags);
+ if (!new_charset)
{
DBUG_PRINT("error",("Couldn't set default character set"));
DBUG_RETURN(TRUE); /* error */
}
- default_charset_info = new;
+ default_charset_info = new_charset;
DBUG_RETURN(FALSE);
}
diff --git a/mysys/default.c b/mysys/default.c
index 126c0270a17..e2e80f36a68 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -146,7 +146,7 @@ void load_defaults(const char *conf_file, const char **groups,
&group))
goto err;
#endif
-#ifdef __EMX__
+#if defined(__EMX__) || defined(OS2)
if (getenv("ETC") &&
search_default_file(&args, &alloc, getenv("ETC"), conf_file,
default_ext, &group))
@@ -363,7 +363,7 @@ void print_defaults(const char *conf_file, const char **groups)
GetWindowsDirectory(name,sizeof(name));
printf("%s\\%s%s ",name,conf_file,have_ext ? "" : windows_ext);
#endif
-#ifdef __EMX__
+#if defined(__EMX__) || defined(OS2)
if (getenv("ETC"))
printf("%s\\%s%s ", getenv("ETC"), conf_file, default_ext);
#endif
diff --git a/mysys/getopt.c b/mysys/getopt.c
index a2a3b5bbec9..774cf3b82f4 100644
--- a/mysys/getopt.c
+++ b/mysys/getopt.c
@@ -38,7 +38,7 @@ Cambridge, MA 02139, USA. */
#include <config.h>
#endif
-#if (!defined (__STDC__) || !__STDC__) && !defined(MSDOS)
+#if (!defined (__STDC__) || !__STDC__) && !defined(MSDOS) && !defined(OS2)
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
@@ -176,7 +176,9 @@ static char *posixly_correct;
/* Avoid depending on library functions or files
whose names are inconsistent. */
+#ifndef OS2
char *getenv (const char *);
+#endif
static char *
my_index (const char *str, int chr)
diff --git a/mysys/getopt1.c b/mysys/getopt1.c
index 6068a036e7b..bff76d6e5b2 100644
--- a/mysys/getopt1.c
+++ b/mysys/getopt1.c
@@ -27,7 +27,7 @@ Cambridge, MA 02139, USA. */
#include <global.h>
#include "getopt.h"
-#if (!defined (__STDC__) || !__STDC__) && !defined(MSDOS)
+#if (!defined (__STDC__) || !__STDC__) && !defined(MSDOS) && !defined(OS2)
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
diff --git a/mysys/list.c b/mysys/list.c
index 0a6d900d6b9..c9c863d4cc2 100644
--- a/mysys/list.c
+++ b/mysys/list.c
@@ -72,11 +72,11 @@ void list_free(LIST *root, pbool free_data)
LIST *list_cons(void *data, LIST *list)
{
- LIST *new=(LIST*) my_malloc(sizeof(LIST),MYF(MY_FAE));
- if (!new)
+ LIST *new_charset=(LIST*) my_malloc(sizeof(LIST),MYF(MY_FAE));
+ if (!new_charset)
return 0;
- new->data=data;
- return list_add(list,new);
+ new_charset->data=data;
+ return list_add(list,new_charset);
}
diff --git a/mysys/mf_dirname.c b/mysys/mf_dirname.c
index f4b9e011215..399082a238b 100644
--- a/mysys/mf_dirname.c
+++ b/mysys/mf_dirname.c
@@ -24,7 +24,7 @@ uint dirname_length(const char *name)
{
register my_string pos,gpos;
#ifdef FN_DEVCHAR
- if ((pos=strrchr(name,FN_DEVCHAR)) == 0)
+ if ((pos=(char*)strrchr(name,FN_DEVCHAR)) == 0)
#endif
pos=(char*) name-1;
diff --git a/mysys/mf_format.c b/mysys/mf_format.c
index c4425806e01..7dac46cf0d0 100644
--- a/mysys/mf_format.c
+++ b/mysys/mf_format.c
@@ -65,7 +65,7 @@ my_string fn_format(my_string to, const char *name, const char *dsk,
pack_dirname(dev,dev); /* Put in ./.. and ~/.. */
if (flag & 4)
(void) unpack_dirname(dev,dev); /* Replace ~/.. with dir */
- if ((pos=strchr(name,FN_EXTCHAR)) != NullS)
+ if ((pos=(char*)strchr(name,FN_EXTCHAR)) != NullS)
{
if ((flag & 2) == 0) /* Skall vi byta extension ? */
{
diff --git a/mysys/mf_path.c b/mysys/mf_path.c
index 3158c45470c..9a88b938e2c 100644
--- a/mysys/mf_path.c
+++ b/mysys/mf_path.c
@@ -74,7 +74,7 @@ my_string my_path(my_string to, const char *progname,
/* test if file without filename is found in path */
/* Returns to if found and to has dirpart if found, else NullS */
-#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
+#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2)
#define F_OK 0
#define PATH_SEP ';'
#define PROGRAM_EXTENSION ".exe"
diff --git a/mysys/mf_qsort.c b/mysys/mf_qsort.c
index 7074abac96e..032a1a28a72 100644
--- a/mysys/mf_qsort.c
+++ b/mysys/mf_qsort.c
@@ -52,7 +52,7 @@
#define MAX_THRESH 8
/* Stack node declarations used to store unfulfilled partition obligations. */
-typedef struct
+typedef struct _qsort_stack_node
{
char *lo;
char *hi;
@@ -109,7 +109,7 @@ qsort_t qsort(void *base_ptr, size_t total_elems, size_t size, qsort_cmp cmp)
if (total_elems > MAX_THRESH)
{
- char *lo = base_ptr;
+ char *lo = (char*) base_ptr;
char *hi = &lo[size * (total_elems - 1)];
stack_node stack[STACK_SIZE]; /* Largest size needed for 32-bit int!!! */
stack_node *top = stack + 1;
diff --git a/mysys/mf_tempfile.c b/mysys/mf_tempfile.c
index b2c0e89b9e4..2cdd720edbd 100644
--- a/mysys/mf_tempfile.c
+++ b/mysys/mf_tempfile.c
@@ -25,7 +25,7 @@
#endif
#ifdef HAVE_TEMPNAM
-#ifndef MSDOS
+#if !defined( MSDOS) && !defined(OS2)
extern char **environ;
#endif
#endif
@@ -122,12 +122,19 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
to[1]= 0;
dir=to;
}
- old_env=environ;
+#ifdef OS2
+ // changing environ variable doesn't work with VACPP
+ char buffer[256];
+ sprintf( buffer, "TMP=%s", dir);
+ putenv( buffer);
+#else
+ old_env= (char**) environ;
if (dir)
{ /* Don't use TMPDIR if dir is given */
- environ=temp_env;
+ environ=(const char**) temp_env;
temp_env[0]=0;
}
+#endif
if ((res=tempnam((char*) dir, (char*) prefix)))
{
strmake(to,res,FN_REFLEN-1);
@@ -142,7 +149,9 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
{
DBUG_PRINT("error",("Got error: %d from tempnam",errno));
}
- environ=old_env;
+#ifndef OS2
+ environ=(const char**) old_env;
+#endif
}
#else
{
diff --git a/mysys/my_clock.c b/mysys/my_clock.c
index d13d69a7b88..e7d1758fa2e 100644
--- a/mysys/my_clock.c
+++ b/mysys/my_clock.c
@@ -18,14 +18,14 @@
#define USES_TYPES
#include "global.h"
-#if !defined(_MSC_VER) && !defined(__BORLANDC__)
+#if !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(OS2)
#include "mysys_priv.h"
#include <sys/times.h>
#endif
long my_clock(void)
{
-#if !defined(MSDOS) && !defined(__WIN__)
+#if !defined(MSDOS) && !defined(__WIN__) && !defined(OS2)
struct tms tmsbuf;
VOID(times(&tmsbuf));
return (tmsbuf.tms_utime + tmsbuf.tms_stime);
diff --git a/mysys/my_copy.c b/mysys/my_copy.c
index be131873118..9b02d84d063 100644
--- a/mysys/my_copy.c
+++ b/mysys/my_copy.c
@@ -81,7 +81,7 @@ int my_copy(const char *from, const char *to, myf MyFlags)
if (MyFlags & MY_HOLD_ORIGINAL_MODES && new_file_stat)
DBUG_RETURN(0); /* File copyed but not stat */
VOID(chmod(to, stat_buff.st_mode & 07777)); /* Copy modes */
-#if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__)
+#if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
VOID(chown(to, stat_buff.st_uid,stat_buff.st_gid)); /* Copy ownership */
#endif
#if !defined(VMS) && !defined(__ZTC__)
diff --git a/mysys/my_create.c b/mysys/my_create.c
index ee5d9aa41f3..5a10b0fd8b5 100644
--- a/mysys/my_create.c
+++ b/mysys/my_create.c
@@ -20,7 +20,7 @@
#include <my_dir.h>
#include "mysys_err.h"
#include <errno.h>
-#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
+#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2)
#include <share.h>
#endif
@@ -48,7 +48,7 @@ File my_create(const char *FileName, int CreateFlags, int access_flags,
#elif defined(VMS)
fd = open((my_string) FileName, access_flags | O_CREAT, 0,
"ctx=stm","ctx=bin");
-#elif defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
+#elif defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2)
if (access_flags & O_SHARE)
fd = sopen((my_string) FileName, access_flags | O_CREAT | O_BINARY,
SH_DENYNO, MY_S_IREAD | MY_S_IWRITE);
diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c
index b49737b2a61..6bdea813fe4 100644
--- a/mysys/my_getwd.c
+++ b/mysys/my_getwd.c
@@ -28,6 +28,9 @@
#include <dos.h>
#include <direct.h>
#endif
+#if defined(OS2)
+#include <direct.h>
+#endif
#ifdef __EMX__
// chdir2 support also drive change
@@ -93,16 +96,16 @@ int my_setwd(const char *dir, myf MyFlags)
int res;
size_s length;
my_string start,pos;
-#if defined(VMS) || defined(MSDOS)
+#if defined(VMS) || defined(MSDOS) || defined(OS2)
char buff[FN_REFLEN];
#endif
DBUG_ENTER("my_setwd");
DBUG_PRINT("my",("dir: '%s' MyFlags %d", dir, MyFlags));
start=(my_string) dir;
-#if defined(MSDOS) /* MSDOS chdir can't change drive */
+#if defined(MSDOS) || defined(OS2) /* OS2/MSDOS chdir can't change drive */
#if !defined(_DDL) && !defined(WIN32)
- if ((pos=strchr(dir,FN_DEVCHAR)) != 0)
+ if ((pos=(char*) strchr(dir,FN_DEVCHAR)) != 0)
{
uint drive,drives;
@@ -110,8 +113,13 @@ int my_setwd(const char *dir, myf MyFlags)
drive=(uint) (toupper(dir[0])-'A'+1); drives= (uint) -1;
if ((pos-(byte*) dir) == 2 && drive > 0 && drive < 32)
{
+#ifdef OS2
+ _chdrive(drive);
+ drives = _getdrive();
+#else
_dos_setdrive(drive,&drives);
_dos_getdrive(&drives);
+#endif
}
if (drive != drives)
{
diff --git a/mysys/my_init.c b/mysys/my_init.c
index b5005b82478..c3b9cecf86e 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -74,7 +74,7 @@ void my_init(void)
pthread_init(); /* Must be called before DBUG_ENTER */
#endif
my_thread_global_init();
-#ifndef __WIN__
+#if !defined( __WIN__) && !defined(OS2)
sigfillset(&my_signals); /* signals blocked by mf_brkhant */
#endif
#endif /* THREAD */
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index 0f4a5261fba..f9774d8a4aa 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -27,7 +27,9 @@
# include <dirent.h>
# define NAMLEN(dirent) strlen((dirent)->d_name)
#else
+#ifndef OS2
# define dirent direct
+#endif
# define NAMLEN(dirent) (dirent)->d_namlen
# if defined(HAVE_SYS_NDIR_H)
# include <sys/ndir.h>
@@ -50,6 +52,11 @@
#include <iodef.h>
#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
@@ -337,9 +344,7 @@ my_string directory_file_name (my_string dst, const char *src)
*****************************************************************************
*/
-MY_DIR *my_dir(path, MyFlags)
-const char *path;
-myf MyFlags;
+MY_DIR *my_dir(const char *path, myf MyFlags)
{
struct fileinfo *fnames;
char *buffer, *obuffer, *tempptr;
@@ -475,9 +480,7 @@ error:
** At MSDOS you always get stat of files, but time is in packed MSDOS-format
******************************************************************************/
-MY_DIR *my_dir(path, MyFlags)
-const char *path;
-myf MyFlags;
+MY_DIR *my_dir(const char* path, myf MyFlags)
{
struct fileinfo *fnames;
char *buffer, *obuffer, *tempptr;
diff --git a/mysys/my_lock.c b/mysys/my_lock.c
index a3508018837..c002f447f59 100644
--- a/mysys/my_lock.c
+++ b/mysys/my_lock.c
@@ -38,12 +38,6 @@
int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
myf MyFlags)
{
-#ifdef __EMX__
- FILELOCK LockArea = {0,0}, UnlockArea = {0,0};
- APIRET rc = 0;
- fpos_t oldpos;
- int lockflags = 0;
-#endif
#ifdef HAVE_FCNTL
int value;
ALARM_VARIABLES;
@@ -56,54 +50,12 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
#else
if (my_disable_locking)
DBUG_RETURN(0);
-#if defined(__EMX__)
- if (locktype == F_UNLCK) {
- UnlockArea.lOffset = start;
- if (length)
- UnlockArea.lRange = length;
- else
- UnlockArea.lRange = 0x7FFFFFFFL;
- } else
- if (locktype == F_RDLCK || locktype == F_WRLCK) {
- if (locktype == F_RDLCK) lockflags |= 1;
- LockArea.lOffset = start;
- if (length)
- LockArea.lRange = length;
- else
- LockArea.lRange = 0x7FFFFFFFL;
- } else {
- my_errno = EINVAL;
- DBUG_RETURN(-1);
- }
- if (!LockArea.lRange && !UnlockArea.lRange)
+
+#if defined(__EMX__) || defined(OS2)
+
+ if (!_lock64( fd, locktype, start, length, MyFlags))
DBUG_RETURN(0);
- if (MyFlags & MY_DONT_WAIT) {
- if (!(rc = DosSetFileLocks(fd,&UnlockArea,&LockArea,0,lockflags)))
- DBUG_RETURN(0); /* Lock was OK */
- if (rc == 175 && locktype == F_RDLCK) {
- lockflags &= ~1;
- rc = DosSetFileLocks(fd,&UnlockArea,&LockArea,0,lockflags);
- }
- if (rc == 33) { /* Lock Violation */
- DBUG_PRINT("info",("Was locked, trying with timeout"));
- rc = DosSetFileLocks(fd,&UnlockArea,&LockArea,MY_HOW_OFTEN_TO_ALARM * 1000,lockflags);
- }
- if (!rc) DBUG_RETURN(0);
- if (rc == 33) errno = EAGAIN;
- else {
- errno = EINVAL;
- printf("Error: DosSetFileLocks() == %d\n",rc);
- }
- } else {
- while (rc = DosSetFileLocks(fd,&UnlockArea,&LockArea,
- MY_HOW_OFTEN_TO_ALARM * 1000,lockflags) && (rc == 33 || rc == 175)) {
- printf(".");
- if (rc == 175) lockflags &= ~1;
- }
- if (!rc) DBUG_RETURN(0);
- errno = EINVAL;
- printf("Error: DosSetFileLocks() == %d\n",rc);
- }
+
#elif defined(HAVE_LOCKING)
/* Windows */
{
diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c
index 6cae6fe3a4d..c2df22ec7ec 100644
--- a/mysys/my_malloc.c
+++ b/mysys/my_malloc.c
@@ -33,7 +33,7 @@ gptr my_malloc(unsigned int Size, myf MyFlags)
if (!Size)
Size=1; /* Safety */
- if ((point = malloc(Size)) == NULL)
+ if ((point = (char*)malloc(Size)) == NULL)
{
my_errno=errno;
if (MyFlags & MY_FAE)
diff --git a/mysys/my_mkdir.c b/mysys/my_mkdir.c
index 773cd26cb03..3685312132c 100644
--- a/mysys/my_mkdir.c
+++ b/mysys/my_mkdir.c
@@ -28,8 +28,8 @@ int my_mkdir(const char *dir, int Flags, myf MyFlags)
DBUG_ENTER("my_dir");
DBUG_PRINT("enter",("dir: %s",dir));
-#ifdef __WIN__
- if (mkdir(dir))
+#if defined(__WIN__) || defined(OS2)
+ if (mkdir((char*) dir))
#else
if (mkdir((char*) dir, Flags & my_umask_dir))
#endif
diff --git a/mysys/my_open.c b/mysys/my_open.c
index fcf1be575c8..2ed1af1eca1 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -20,7 +20,7 @@
#include "mysys_err.h"
#include <my_dir.h>
#include <errno.h>
-#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
+#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2)
#include <share.h>
#endif
@@ -35,7 +35,7 @@ File my_open(const char *FileName, int Flags, myf MyFlags)
DBUG_ENTER("my_open");
DBUG_PRINT("my",("Name: '%s' Flags: %d MyFlags: %d",
FileName, Flags, MyFlags));
-#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
+#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2)
if (Flags & O_SHARE)
fd = sopen((my_string) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO,
MY_S_IREAD | MY_S_IWRITE);
diff --git a/mysys/my_os2cond.c b/mysys/my_os2cond.c
new file mode 100644
index 00000000000..c436ad9a0e9
--- /dev/null
+++ b/mysys/my_os2cond.c
@@ -0,0 +1,188 @@
+/* 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; either
+ version 2 of the License, or (at your option) any later version.
+
+ 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>
+//#undef getpid
+#include <process.h>
+#include <sys/timeb.h>
+
+int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
+{
+ APIRET rc = 0;
+ HEV event;
+ cond->waiting=0;
+ /* Warp3 FP29 or Warp4 FP4 or better required */
+ rc = DosCreateEventSem( NULL, &cond->semaphore, 0x0800, 0);
+ if (rc)
+ return ENOMEM;
+
+ return 0;
+}
+
+int pthread_cond_destroy(pthread_cond_t *cond)
+{
+ APIRET rc;
+
+ do {
+ rc = DosCloseEventSem(cond->semaphore);
+ if (rc == 301) DosPostEventSem(cond->semaphore);
+ } while (rc == 301);
+ if (rc)
+ return EINVAL;
+
+ return 0;
+}
+
+
+int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
+{
+ APIRET rc;
+ int rval;
+
+ rval = 0;
+ cond->waiting++;
+
+ if (mutex) pthread_mutex_unlock(mutex);
+
+ rc = DosWaitEventSem(cond->semaphore,SEM_INDEFINITE_WAIT);
+ if (rc != 0)
+ 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;
+ APIRET rc;
+ int rval;
+
+ _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;
+
+ rval = 0;
+ cond->waiting++;
+
+ if (mutex) pthread_mutex_unlock(mutex);
+
+ rc = DosWaitEventSem(cond->semaphore, timeout);
+ if (rc != 0)
+ rval = ETIME;
+
+ if (mutex) pthread_mutex_lock(mutex);
+
+ cond->waiting--;
+
+ return rval;
+}
+
+
+int pthread_cond_signal(pthread_cond_t *cond)
+{
+ APIRET rc;
+
+ /* Bring the next thread off the condition queue: */
+ rc = DosPostEventSem(cond->semaphore);
+ return 0;
+}
+
+
+int pthread_cond_broadcast(pthread_cond_t *cond)
+{
+ int i;
+ APIRET rc;
+
+ /*
+ * Enter a loop to bring all threads off the
+ * condition queue:
+ */
+ i = cond->waiting;
+ while (i--) rc = 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
new file mode 100644
index 00000000000..36f56d3ed2e
--- /dev/null
+++ b/mysys/my_os2dirsrch.c
@@ -0,0 +1,182 @@
+/* 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; either
+ version 2 of the License, or (at your option) any later version.
+
+ 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)
+
+//#define _DEBUG
+
+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, /* Address of the ASCIIZ path name of the file or subdirectory to be found. */
+ &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. */
+ &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), /* The 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;
+
+ strcpy( buffer, path);
+ strcat( buffer, "*.*");
+
+#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;
+ //FILEFINDBUF3 buf3;
+ 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), /* The 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 */)
+ strcpy( dir->buf3.achName, ""); // 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
new file mode 100644
index 00000000000..2afe0f609f1
--- /dev/null
+++ b/mysys/my_os2dirsrch.h
@@ -0,0 +1,77 @@
+/* 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; either
+ version 2 of the License, or (at your option) any later version.
+
+ 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;
+ //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;
+ char name[260];
+ //uint16 wr_date;
+ //uint16 wr_time;
+};
+
+struct dirent
+{
+ //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;
+ char d_name[260];
+ //uint16 wr_date;
+ //uint16 wr_time;
+};
+
+struct DIR
+{
+ HDIR hdir;
+ FILEFINDBUF3 buf3;
+ struct dirent ent;
+};
+
+DIR *opendir ( char *);
+struct dirent *readdir (DIR *);
+int closedir (DIR *);
+
+//#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);
+
+#ifdef __cplusplus_00
+}
+#endif
+
+#endif // __MY_OS2DIRSRCH2_H__
diff --git a/mysys/my_os2dlfcn.c b/mysys/my_os2dlfcn.c
new file mode 100644
index 00000000000..0b0b5518eff
--- /dev/null
+++ b/mysys/my_os2dlfcn.c
@@ -0,0 +1,74 @@
+/* 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; either
+ version 2 of the License, or (at your option) any later version.
+
+ 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
new file mode 100644
index 00000000000..7f84d430230
--- /dev/null
+++ b/mysys/my_os2dlfcn.h0
@@ -0,0 +1,39 @@
+/* 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; either
+ version 2 of the License, or (at your option) any later version.
+
+ 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
new file mode 100644
index 00000000000..8964e562ea1
--- /dev/null
+++ b/mysys/my_os2file64.c
@@ -0,0 +1,341 @@
+/* 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; either
+ version 2 of the License, or (at your option) any later version.
+
+ 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 */
+
+ // set errno
+ _OS2errno( rc);
+ // seek failed
+ return(-1);
+}
+
+inline _SetFileLocksL(HFILE hFile,
+ PFILELOCKL pflUnlock,
+ PFILELOCKL pflLock,
+ ULONG timeout,
+ ULONG flags)
+{
+ if (_DosSetFileLocksL)
+ return _DosSetFileLocksL( hFile, pflUnlock, pflLock, timeout, flags);
+
+ 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 */
+
+ // set errno
+ _OS2errno( rc);
+ // lock failed
+ return(-1);
+}
+
+int _sopen64( 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)
+ {
+ // set errno
+ _OS2errno( rc);
+ return -1;
+ }
+
+ if (oflag & O_APPEND)
+ _lseek64( hf, 0L, SEEK_END);
+
+ return hf;
+}
+
+inline int open( const char *name, int oflag)
+{
+ return _sopen64( name, oflag, OPEN_SHARE_DENYNONE, S_IREAD | S_IWRITE);
+}
+
+inline int open( const char *name, int oflag, int mask)
+{
+ return _sopen64( name, oflag, OPEN_SHARE_DENYNONE, mask);
+}
+
+inline int sopen( const char *name, int oflag, int shflag, int mask)
+{
+ return _sopen64( name, oflag, shflag, mask);
+}
diff --git a/mysys/my_os2mutex.c b/mysys/my_os2mutex.c
new file mode 100644
index 00000000000..0ae6ae86d8c
--- /dev/null
+++ b/mysys/my_os2mutex.c
@@ -0,0 +1,98 @@
+/*
+ * 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
+//#include <pthread.h>
+//#include "pthread_private.h"
+
+int
+pthread_mutex_init(pthread_mutex_t * mutex,
+ const pthread_mutexattr_t * mutex_attr)
+{
+ APIRET rc = 0;
+
+ rc = DosCreateMutexSem(NULL,mutex,0,0);
+
+ /* Return the completion status: */
+ return (0);
+}
+
+int
+pthread_mutex_destroy(pthread_mutex_t * mutex)
+{
+ APIRET rc = 0;
+
+
+ do {
+ rc = DosCloseMutexSem(*mutex);
+ if (rc == 301) DosReleaseMutexSem(*mutex);
+ } while (rc == 301);
+
+ *mutex = 0;
+
+ /* Return the completion status: */
+ return (0);
+}
+
+
+int
+pthread_mutex_lock(pthread_mutex_t * mutex)
+{
+ int ret = 0;
+ int status = 0;
+ APIRET rc = 0;
+
+ rc = DosRequestMutexSem(*mutex,SEM_INDEFINITE_WAIT);
+ if (rc)
+ return(EINVAL);
+ /* Return the completion status: */
+ return (0);
+}
+
+int
+pthread_mutex_unlock(pthread_mutex_t * mutex)
+{
+ int ret = 0;
+ APIRET rc = 0;
+ int status;
+
+ rc = DosReleaseMutexSem(*mutex);
+
+ /* Return the completion status: */
+ return (0);
+}
+#endif
diff --git a/mysys/my_os2thread.c b/mysys/my_os2thread.c
new file mode 100644
index 00000000000..017ba7f316b
--- /dev/null
+++ b/mysys/my_os2thread.c
@@ -0,0 +1,126 @@
+/* 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; either
+ version 2 of the License, or (at your option) any later version.
+
+ 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.
+*/
+
+static pthread_handler_decl(pthread_start,param)
+{
+ 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));
+ return 0; /* Safety */
+}
+
+
+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
new file mode 100644
index 00000000000..25d543d0768
--- /dev/null
+++ b/mysys/my_os2tls.c
@@ -0,0 +1,144 @@
+/* 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; either
+ version 2 of the License, or (at your option) any later version.
+
+ 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;
+}
diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c
index a3a193650df..8bdbc0f7fd8 100644
--- a/mysys/my_pthread.c
+++ b/mysys/my_pthread.c
@@ -145,7 +145,7 @@ struct tm *localtime_r(const time_t *clock, struct tm *res)
** Author: Gary Wisniewski <garyw@spidereye.com.au>, much modified by Monty
****************************************************************************/
-#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(sigwait) && !defined(__WIN__) && !defined(HAVE_rts_threads) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS)
+#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(sigwait) && !defined(__WIN__) && !defined(HAVE_rts_threads) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(OS2)
#if !defined(DONT_USE_SIGSUSPEND)
diff --git a/mysys/my_realloc.c b/mysys/my_realloc.c
index c9d8edd6ddf..7ab75d47619 100644
--- a/mysys/my_realloc.c
+++ b/mysys/my_realloc.c
@@ -49,7 +49,7 @@ gptr my_realloc(gptr oldpoint, uint Size, myf MyFlags)
free(oldpoint);
}
#else
- if ((point = realloc(oldpoint,Size)) == NULL)
+ if ((point = (char*)realloc(oldpoint,Size)) == NULL)
{
if (MyFlags & MY_FREE_ON_ERROR)
my_free(oldpoint,MyFLAGS);
diff --git a/mysys/my_redel.c b/mysys/my_redel.c
index 0cc17481dab..16ec77394d2 100644
--- a/mysys/my_redel.c
+++ b/mysys/my_redel.c
@@ -91,7 +91,7 @@ int my_copystat(const char *from, const char *to, int MyFlags)
return 1;
VOID(chmod(to, statbuf.st_mode & 07777)); /* Copy modes */
-#if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__)
+#if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
if (statbuf.st_nlink > 1 && MyFlags & MY_LINK_WARNING)
{
if (MyFlags & MY_LINK_WARNING)
diff --git a/mysys/my_static.c b/mysys/my_static.c
index 3fc68455841..00061893cdc 100644
--- a/mysys/my_static.c
+++ b/mysys/my_static.c
@@ -20,7 +20,7 @@
a shared library
*/
-#ifndef stdin
+#if !defined(stdin) || defined(OS2)
#include "mysys_priv.h"
#include "my_static.h"
#include "my_alarm.h"
diff --git a/mysys/my_tempnam.c b/mysys/my_tempnam.c
index ac982538668..7da037e8d49 100644
--- a/mysys/my_tempnam.c
+++ b/mysys/my_tempnam.c
@@ -26,7 +26,7 @@
#endif
#ifdef HAVE_TEMPNAM
-#ifndef MSDOS
+#if !defined( MSDOS) && !defined(OS2)
extern char **environ;
#endif
#endif
@@ -91,14 +91,23 @@ my_string my_tempnam(const char *dir, const char *pfx,
temp[1]= 0;
dir=temp;
}
- old_env=environ;
+#ifdef OS2
+ // changing environ variable doesn't work with VACPP
+ char buffer[256];
+ sprintf( buffer, "TMP=%s", dir);
+ putenv( buffer);
+#else
+ old_env=(char**)environ;
if (dir)
{ /* Don't use TMPDIR if dir is given */
- environ=temp_env;
+ environ=(const char**)temp_env;
temp_env[0]=0;
}
+#endif
res=tempnam((char*) dir,(my_string) pfx); /* Use stand. dir with prefix */
- environ=old_env;
+#ifndef OS2
+ environ=(const char**)old_env;
+#endif
if (!res)
DBUG_PRINT("error",("Got error: %d from tempnam",errno));
return res;
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index dab281e4dc6..e1f9e23912e 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -72,7 +72,7 @@ my_bool my_thread_global_init(void)
pthread_mutex_init(&THR_LOCK_heap,MY_MUTEX_INIT_FAST);
pthread_mutex_init(&THR_LOCK_net,MY_MUTEX_INIT_FAST);
pthread_mutex_init(&THR_LOCK_charset,MY_MUTEX_INIT_FAST);
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
win_pthread_init();
#endif
#ifndef HAVE_LOCALTIME_R
@@ -160,11 +160,11 @@ void my_thread_end(void)
pthread_cond_destroy(&tmp->suspend);
#endif
pthread_mutex_destroy(&tmp->mutex);
-#if !defined(__WIN__) || defined(USE_TLS)
+#if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS)
free(tmp);
#endif
}
-#if !defined(__WIN__) || defined(USE_TLS)
+#if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS)
pthread_setspecific(THR_KEY_mysys,0);
#endif
}
diff --git a/mysys/my_write.c b/mysys/my_write.c
index 61d6c7d2180..640043192ef 100644
--- a/mysys/my_write.c
+++ b/mysys/my_write.c
@@ -19,6 +19,46 @@
#include "mysys_err.h"
#include <errno.h>
+#ifdef OS2
+
+int _write64( int fd, const void *buffer, unsigned int count)
+{
+ APIRET rc;
+ ULONG actual;
+
+ rc = DosWrite( fd, (PVOID) buffer, count, &actual);
+
+ switch (rc) {
+ case 0: /* NO_ERROR */
+ errno = 0;
+ return( actual);
+ break;
+ case ERROR_INVALID_FUNCTION:
+ errno = EPERM;
+ break;
+ case ERROR_ACCESS_DENIED:
+ errno = EACCESS;
+ break;
+ case ERROR_INVALID_HANDLE:
+ errno = EBADF;
+ break;
+ case ERROR_DISK_FULL:
+ errno = ENOSPC;
+ break;
+ default:
+ errno = EINVAL;
+ break;
+ }
+ // write failed
+ return(-1);
+}
+
+// redirect call
+#define write _write64
+
+#endif // OS2
+
+
/* Write a chunk of bytes to a file */
uint my_write(int Filedes, const byte *Buffer, uint Count, myf MyFlags)
diff --git a/mysys/test_charset.c b/mysys/test_charset.c
index a04bdbd9a58..6a5183d2cd3 100644
--- a/mysys/test_charset.c
+++ b/mysys/test_charset.c
@@ -22,7 +22,7 @@
#include <stdio.h>
-extern void _print_csinfo();
+extern void _print_csinfo(CHARSET_INFO *cs);
int main(int argc, char **argv) {
const char *the_set = MYSQL_CHARSET;
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index 3c641e01d7b..f51f27b7f51 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -37,7 +37,7 @@
static my_bool alarm_aborted=1;
my_bool thr_alarm_inited=0;
-#if !defined(__WIN__) && !defined(__EMX__)
+#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
static pthread_mutex_t LOCK_alarm;
static sigset_t full_signal_set;
@@ -460,7 +460,7 @@ static void *alarm_handler(void *arg __attribute__((unused)))
** thr_alarm for OS/2
*****************************************************************************/
-#elif defined(__EMX__)
+#elif defined(__EMX__) || defined(OS2)
#define INCL_BASE
#define INCL_NOPMAPI
@@ -775,8 +775,10 @@ static sig_handler print_signal_warning(int sig)
#ifdef DONT_REMEMBER_SIGNAL
sigset(sig,print_signal_warning); /* int. thread system calls */
#endif
+#ifndef OS2
if (sig == SIGALRM)
alarm(2); /* reschedule alarm */
+#endif
}
#endif /* USE_ONE_SIGNAL_HAND */
@@ -793,6 +795,7 @@ static void *signal_hand(void *arg __attribute__((unused)))
VOID(pthread_cond_signal(&COND_thread_count)); /* Tell main we are ready */
pthread_mutex_unlock(&LOCK_thread_count);
+#ifndef OS2
sigemptyset(&set); /* Catch all signals */
sigaddset(&set,SIGINT);
sigaddset(&set,SIGQUIT);
@@ -809,6 +812,7 @@ static void *signal_hand(void *arg __attribute__((unused)))
#else
puts("Starting signal handling thread");
#endif
+#endif /* OS2 */
printf("server alarm: %d thread alarm: %d\n",
THR_SERVER_ALARM,THR_CLIENT_ALARM);
DBUG_PRINT("info",("Starting signal and alarm handling thread"));
@@ -831,7 +835,9 @@ static void *signal_hand(void *arg __attribute__((unused)))
case SIGINT:
case SIGQUIT:
case SIGTERM:
+#ifndef OS2
case SIGHUP:
+#endif
printf("Aborting nicely\n");
end_thr_alarm();
break;
@@ -841,11 +847,13 @@ static void *signal_hand(void *arg __attribute__((unused)))
exit(1);
return 0; /* Keep some compilers happy */
#endif
+#ifndef OS2
#ifdef USE_ONE_SIGNAL_HAND
case THR_SERVER_ALARM:
process_alarm(sig);
break;
#endif
+#endif /* OS2 */
}
}
}
@@ -866,6 +874,7 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
pthread_cond_init(&COND_thread_count,NULL);
/* Start a alarm handling thread */
+#ifndef OS2
sigemptyset(&set);
sigaddset(&set,SIGINT);
sigaddset(&set,SIGQUIT);
@@ -883,6 +892,7 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
sigaddset(&set,THR_CLIENT_ALARM);
VOID(pthread_sigmask(SIG_UNBLOCK, &set, (sigset_t*) 0));
#endif
+#endif /* OS2 */
pthread_attr_init(&thr_attr);
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS);
diff --git a/mysys/tree.c b/mysys/tree.c
index 002062d9f0e..cd05a17fd72 100644
--- a/mysys/tree.c
+++ b/mysys/tree.c
@@ -133,7 +133,7 @@ static void delete_tree_element(TREE *tree, TREE_ELEMENT *element)
if (tree->free)
(*tree->free)(ELEMENT_KEY(tree,element));
if (tree->with_delete)
- my_free((void*) element,MYF(0));
+ my_free((char*) element,MYF(0));
}
}