Initial revision

From-SVN: r102074
This commit is contained in:
Tom Tromey
2005-07-16 00:30:23 +00:00
parent 6f4434b39b
commit f911ba985a
4557 changed files with 1000262 additions and 0 deletions
@@ -0,0 +1,8 @@
*.o
*.a
*.lo
*.la
.libs
.deps
Makefile
Makefile.in
@@ -0,0 +1,8 @@
*.o
*.a
*.lo
*.la
.libs
.deps
Makefile
Makefile.in
@@ -0,0 +1,10 @@
## Input file for automake to generate the Makefile.in used by configure
EXTRA_DIST = \
target_native_io.h \
target_native_misc.h \
target_native.h \
target_native_math_float.h \
target_native_network.h \
target_native_file.h \
target_native_math_int.h
@@ -0,0 +1,79 @@
/* ???.h - ???
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
/*
Description: Linux target global defintions
Systems : all
*/
#ifndef __TARGET_NATIVE__
#define __TARGET_NATIVE__
/****************************** Includes *******************************/
/* do not move; needed here because of some macro definitions */
#include <config.h>
#include <stdlib.h>
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
/***************************** Datatypes *******************************/
/***************************** Variables *******************************/
/****************************** Macros *********************************/
/***************************** Functions *******************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
/* include rest of definitions from generic file (do not move it to
another position!) */
#include "target_generic.h"
#endif /* __TARGET_NATIVE__ */
/* end of file */
@@ -0,0 +1,79 @@
/* ???.h - ???
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
/*
Description: Linux target defintions of file functions
Systems : all
*/
#ifndef __TARGET_NATIVE_FILE__
#define __TARGET_NATIVE_FILE__
/****************************** Includes *******************************/
/* do not move; needed here because of some macro definitions */
#include <config.h>
#include <stdlib.h>
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
/***************************** Datatypes *******************************/
/***************************** Variables *******************************/
/****************************** Macros *********************************/
/***************************** Functions *******************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
/* include rest of definitions from generic file (do not move it to
another position!) */
#include "target_generic_file.h"
#endif /* __TARGET_NATIVE_FILE__ */
/* end of file */
@@ -0,0 +1,78 @@
/* ???.h - ???
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
/*
Description: Linux target defintions of miscellaneous functions
Systems : all
*/
#ifndef __TARGET_NATIVE_IO__
#define __TARGET_NATIVE_IO__
/****************************** Includes *******************************/
/* do not move; needed here because of some macro definitions */
#include <config.h>
#include <stdlib.h>
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
/***************************** Datatypes *******************************/
/***************************** Variables *******************************/
/****************************** Macros *********************************/
/***************************** Functions *******************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
/* include rest of definitions from generic file (do not move it to
another position!) */
#include "target_generic_io.h"
#endif /* __TARGET_NATIVE_MISC__ */
/* end of file */
@@ -0,0 +1,80 @@
/* ???.h - ???
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
/*
Description: Linux target defintions of float/double constants/
macros/functions
Systems : all
*/
#ifndef __TARGET_NATIVE_MATH_FLOAT__
#define __TARGET_NATIVE_MATH_FLOAT__
/****************************** Includes *******************************/
/* do not move; needed here because of some macro definitions */
#include <config.h>
#include <stdlib.h>
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
/***************************** Datatypes *******************************/
/***************************** Variables *******************************/
/****************************** Macros *********************************/
/***************************** Functions *******************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
/* include rest of definitions from generic file (do not move it to
another position!) */
#include "target_generic_math_float.h"
#endif /* __TARGET_NATIVE_MATH_FLOAT__ */
/* end of file */
@@ -0,0 +1,80 @@
/* ???.h - ???
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
/*
Description: Linux target defintions of int/int64 constants/
macros/functions
Systems : all
*/
#ifndef __TARGET_NATIVE_MATH_INT__
#define __TARGET_NATIVE_MATH_INT__
/****************************** Includes *******************************/
/* do not move; needed here because of some macro definitions */
#include <config.h>
#include <stdlib.h>
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
/***************************** Datatypes *******************************/
/***************************** Variables *******************************/
/****************************** Macros *********************************/
/***************************** Functions *******************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
/* include rest of definitions from generic file (do not move it to
another position!) */
#include "target_generic_math_int.h"
#endif /* __TARGET_NATIVE_MATH_INT__ */
/* end of file */
@@ -0,0 +1,79 @@
/* ???.h - ???
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
/*
Description: Linux target defintions of miscellaneous functions
Systems : all
*/
#ifndef __TARGET_NATIVE_MISC__
#define __TARGET_NATIVE_MISC__
/****************************** Includes *******************************/
/* do not move; needed here because of some macro definitions */
#include <config.h>
#include <stdlib.h>
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
/***************************** Datatypes *******************************/
/***************************** Variables *******************************/
/****************************** Macros *********************************/
/***************************** Functions *******************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
/* include rest of definitions from generic file (do not move it to
another position!) */
#include "target_generic_misc.h"
#endif /* __TARGET_NATIVE_MISC__ */
/* end of file */
@@ -0,0 +1,79 @@
/* ???.h - ???
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
/*
Description: Linux target defintions of network functions
Systems : all
*/
#ifndef __TARGET_NATIVE_NETWORK__
#define __TARGET_NATIVE_NETWORK__
/****************************** Includes *******************************/
/* do not move; needed here because of some macro definitions */
#include <config.h>
#include <stdlib.h>
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
/***************************** Datatypes *******************************/
/***************************** Variables *******************************/
/****************************** Macros *********************************/
/***************************** Functions *******************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
/* include rest of definitions from generic file (do not move it to
another position!) */
#include "target_generic_network.h"
#endif /* __TARGET_NATIVE_NETWORK__ */
/* end of file */
@@ -0,0 +1,5 @@
## Input file for automake to generate the Makefile.in used by configure
SUBDIRS = Linux generic
EXTRA_DIST = readme.txt
@@ -0,0 +1,8 @@
*.o
*.a
*.lo
*.la
.libs
.deps
Makefile
Makefile.in
@@ -0,0 +1,10 @@
## Input file for automake to generate the Makefile.in used by configure
EXTRA_DIST = \
target_generic_io.h \
target_generic_misc.h \
target_generic.h \
target_generic_math_float.h \
target_generic_network.h \
target_generic_file.h \
target_generic_math_int.h
@@ -0,0 +1,171 @@
/* generic_math_int64.h - Native methods for 64bit math operations
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
/*
Description: generic target global defintions
Systems : all
*/
#ifndef __TARGET_GENERIC__
#define __TARGET_GENERIC__
/* check if target_native_network.h included */
#ifndef __TARGET_NATIVE__
#error Do NOT INCLUDE generic target files! Include the corresponding native target files instead!
#endif
/****************************** Includes *******************************/
/* do not move; needed here because of some macro definitions */
#include "config.h"
#include <stdlib.h>
#include <errno.h>
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
#define TARGET_NATIVE_OK 1
#define TARGET_NATIVE_ERROR 0
#ifndef TARGET_NATIVE_ERROR_PERMISION_DENIED
#define TARGET_NATIVE_ERROR_PERMISION_DENIED EACCES
#endif
#ifndef TARGET_NATIVE_ERROR_BAD_FILE_DESCRIPTOR
#define TARGET_NATIVE_ERROR_BAD_FILE_DESCRIPTOR EBADF
#endif
#ifndef TARGET_NATIVE_ERROR_FILE_EXISTS
#define TARGET_NATIVE_ERROR_FILE_EXISTS EEXIST
#endif
#ifndef TARGET_NATIVE_ERROR_INPUT_OUTPUT
#define TARGET_NATIVE_ERROR_INPUT_OUTPUT EIO
#endif
#ifndef TARGET_NATIVE_ERROR_TOO_MANY_OPEN_FILES
#define TARGET_NATIVE_ERROR_TOO_MANY_OPEN_FILES EMFILE
#endif
#ifndef TARGET_NATIVE_ERROR_FILENAME_TO_LONG
#define TARGET_NATIVE_ERROR_FILENAME_TO_LONG ENAMETOOLONG
#endif
#ifndef TARGET_NATIVE_ERROR_NO_SUCH_DEVICE
#define TARGET_NATIVE_ERROR_NO_SUCH_DEVICE ENODEV
#endif
#ifndef TARGET_NATIVE_ERROR_NO_SUCH_FILE
#define TARGET_NATIVE_ERROR_NO_SUCH_FILE ENOENT
#endif
#ifndef TARGET_NATIVE_ERROR_NO_SPACE_LEFT
#define TARGET_NATIVE_ERROR_NO_SPACE_LEFT ENOSPC
#endif
#ifndef TARGET_NATIVE_ERROR_DIRECTORY_NOT_EMPTY
#define TARGET_NATIVE_ERROR_DIRECTORY_NOT_EMPTY ENOTEMPTY
#endif
#ifndef TARGET_NATIVE_ERROR_OPERATION_NOT_PERMITTED
#define TARGET_NATIVE_ERROR_OPERATION_NOT_PERMITTED EPERM
#endif
#ifndef TARGET_NATIVE_ERROR_READ_ONLY_FILE_SYSTEM
#define TARGET_NATIVE_ERROR_READ_ONLY_FILE_SYSTEM EROFS
#endif
#ifndef TARGET_NATIVE_ERROR_INVALID_SEEK
#define TARGET_NATIVE_ERROR_INVALID_SEEK ESPIPE
#endif
#ifndef TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL
#define TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL EINTR
#endif
/***************************** Datatypes *******************************/
/***************************** Variables *******************************/
/****************************** Macros *********************************/
/***********************************************************************\
* Name : TARGET_NATIVE_LAST_ERROR
* Purpose : return last error code
* Input : -
* Output : -
* Return : error code
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_LAST_ERROR
#include <errno.h>
#define TARGET_NATIVE_LAST_ERROR() \
errno
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_LAST_ERROR_STRING
* Purpose : return last error string
* Input : -
* Output : -
* Return : error string (read only!)
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_LAST_ERROR_STRING
#include <string.h>
#include <errno.h>
#define TARGET_NATIVE_LAST_ERROR_STRING() \
strerror(errno)
#endif
#ifndef TARGET_NATIVE_LAST_ERROR_STRING_FORMAT
#include <string.h>
#include <errno.h>
#define TARGET_NATIVE_LAST_ERROR_STRING_FORMAT(buffer,bufferSize,format) \
do { \
sprintf(buffer,format); \
strcat(" (error: "); \
strcat(strerror(errno)); \
strcat(")"); \
} while (0)
#endif
/***************************** Functions *******************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* __TARGET_GENERIC__ */
/* end of file */
@@ -0,0 +1,844 @@
/* target_generic_file - Native methods for file operations
Copyright (C) 1998, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
/*
Description: generic target defintions of file functions
Systems : all
*/
#ifndef __TARGET_GENERIC_FILE__
#define __TARGET_GENERIC_FILE__
#ifdef __cplusplus
extern "C" {
#endif
/* check if target_native_file.h included */
#ifndef __TARGET_NATIVE_FILE__
#error Do NOT INCLUDE generic target files! Include the corresponding native target files instead!
#endif
/****************************** Includes *******************************/
/* do not move; needed here because of some macro definitions */
#include "config.h"
#include <stdlib.h>
#include <assert.h>
#include <fcntl.h>
#include "target_native.h"
#include "target_native_math_int.h"
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
#ifndef TARGET_NATIVE_FILE_FILEFLAG_NONE
#define TARGET_NATIVE_FILE_FILEFLAG_NONE 0
#endif
#ifndef TARGET_NATIVE_FILE_FILEFLAG_CREATE
#define TARGET_NATIVE_FILE_FILEFLAG_CREATE O_CREAT
#endif
#ifndef TARGET_NATIVE_FILE_FILEFLAG_CREATE_FORCE
#define TARGET_NATIVE_FILE_FILEFLAG_CREATE_FORCE (O_CREAT|O_EXCL)
#endif
#ifndef TARGET_NATIVE_FILE_FILEFLAG_READ
#define TARGET_NATIVE_FILE_FILEFLAG_READ O_RDONLY
#endif
#ifndef TARGET_NATIVE_FILE_FILEFLAG_WRITE
#define TARGET_NATIVE_FILE_FILEFLAG_WRITE O_WRONLY
#endif
#ifndef TARGET_NATIVE_FILE_FILEFLAG_READWRITE
#define TARGET_NATIVE_FILE_FILEFLAG_READWRITE O_RDWR
#endif
#ifndef TARGET_NATIVE_FILE_FILEFLAG_TRUNCATE
#define TARGET_NATIVE_FILE_FILEFLAG_TRUNCATE O_TRUNC
#endif
#ifndef TARGET_NATIVE_FILE_FILEFLAG_APPEND
#define TARGET_NATIVE_FILE_FILEFLAG_APPEND O_APPEND
#endif
#ifndef TARGET_NATIVE_FILE_FILEFLAG_SYNC
#if !defined (O_SYNC) && defined (O_FSYNC)
#define TARGET_NATIVE_FILE_FILEFLAG_SYNC O_FSYNC
#else
#define TARGET_NATIVE_FILE_FILEFLAG_SYNC O_SYNC
#endif
#endif
#ifndef TARGET_NATIVE_FILE_FILEFLAG_DSYNC
#ifdef O_DSYNC
#define TARGET_NATIVE_FILE_FILEFLAG_DSYNC 0
#else
#define TARGET_NATIVE_FILE_FILEFLAG_DSYNC TARGET_NATIVE_FILE_FILEFLAG_SYNC
#endif
#endif
#ifndef TARGET_NATIVE_FILE_FILEFLAG_BINARY
#define TARGET_NATIVE_FILE_FILEFLAG_BINARY O_BINARY
#endif
#ifndef TARGET_NATIVE_FILE_FILEPERMISSION_NORMAL
#define TARGET_NATIVE_FILE_FILEPERMISSION_NORMAL (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
#endif
#ifndef TARGET_NATIVE_FILE_FILEPERMISSION_PRIVATE
#define TARGET_NATIVE_FILE_FILEPERMISSION_PRIVATE (S_IRUSR | S_IWUSR)
#endif
#ifndef TARGET_NATIVE_FILE_FILEPERMISSION_READONLY
#define TARGET_NATIVE_FILE_FILEPERMISSION_READONLY (~(S_IWRITE|S_IWGRP|S_IWOTH))
#endif
/***************************** Datatypes *******************************/
/***************************** Variables *******************************/
/****************************** Macros *********************************/
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_OPEN
* Purpose : open a file
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : file is created if it does not exist
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_OPEN
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define TARGET_NATIVE_FILE_OPEN(filename,filedescriptor,flags,permissions,result) \
do { \
filedescriptor=open(filename, \
flags, \
permissions \
); \
if (filedescriptor >= 0) \
fcntl (filedescriptor,F_SETFD,FD_CLOEXEC); \
result=(filedescriptor>=0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_OPEN_CREATE
* Purpose : create a file
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : file is created if it does not exist
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_OPEN_CREATE
#define TARGET_NATIVE_FILE_OPEN_CREATE(filename,filedescriptor,result) \
TARGET_NATIVE_FILE_OPEN(filename,\
filedescriptor,\
TARGET_NATIVE_FILE_FILEFLAG_CREATE_FORCE, \
TARGET_NATIVE_FILE_FILEPERMISSION_NORMAL, \
result \
)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_OPEN_READ
* Purpose : open an existing file for reading
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_OPEN_READ
#define TARGET_NATIVE_FILE_OPEN_READ(filename,filedescriptor,result) \
TARGET_NATIVE_FILE_OPEN(filename, \
filedescriptor,\
TARGET_NATIVE_FILE_FILEFLAG_READ, \
TARGET_NATIVE_FILE_FILEPERMISSION_NORMAL, \
result \
)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_OPEN_WRITE
* Purpose : open an existing file for writing
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_OPEN_WRITE
#define TARGET_NATIVE_FILE_OPEN_WRITE(filename,filedescriptor,result) \
TARGET_NATIVE_FILE_OPEN(filename, \
filedescriptor, \
TARGET_NATIVE_FILE_FILEFLAG_WRITE, \
TARGET_NATIVE_FILE_FILEPERMISSION_NORMAL, \
result \
)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_OPEN_READWRITE
* Purpose : create/open a file for reading/writing
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : file is created if it does not exist
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_OPEN_READWRITE
#define TARGET_NATIVE_FILE_OPEN_READWRITE(filename,filedescriptor,result) \
TARGET_NATIVE_FILE_OPEN(filename, \
filedescriptor, \
TARGET_NATIVE_FILE_FILEFLAG_READWRITE, \
TARGET_NATIVE_FILE_FILEPERMISSION_NORMAL, \
result \
)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_OPEN_READWRITE
* Purpose : create/open a file for append
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : file is created if it does not exist
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_OPEN_APPEND
#define TARGET_NATIVE_FILE_OPEN_APPEND(filename,filedescriptor,result) \
TARGET_NATIVE_FILE_OPEN_APPEND(filename, \
filedescriptor, \
TARGET_NATIVE_FILE_FILEFLAG_CREATE_FORCE|TARGET_NATIVE_FILE_FILEFLAG_APPEND, \
TARGET_NATIVE_FILE_FILEPERMISSION_NORMAL, \
result \
)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_CLOSE
* Purpose : close a file
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_CLOSE
#include <unistd.h>
#define TARGET_NATIVE_FILE_CLOSE(filedescriptor,result) \
do { \
result=(close(filedescriptor)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_VALID_FILE_DESCRIPTOR
* Purpose : check if file-descriptor is valid
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_VALID_FILE_DESCRIPTOR
#if defined(HAVE_FCNTL)
#include <unistd.h>
#include <fcntl.h>
#define TARGET_NATIVE_FILE_VALID_FILE_DESCRIPTOR(filedescriptor,result) \
do { \
result=(fcntl(filedescriptor,F_GETFL,0)!=-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while(0)
#elif defined(HAVE_FSTAT)
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define TARGET_NATIVE_FILE_VALID_FILE_DESCRIPTOR(filedescriptor,result) \
do { \
struct stat __stat; \
\
result=(fstat(filedescriptor,&__stat)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while(0)
#else
#error fcntl() nor fstat() available for checking if file descriptor is valid
#endif
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_TELL
* Purpose : get current file position
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_TELL
#include <sys/types.h>
#include <unistd.h>
#define TARGET_NATIVE_FILE_TELL(filedescriptor,offset,result) \
do { \
offset=lseek(filedescriptor,TARGET_NATIVE_MATH_INT_INT64_CONST_0,SEEK_CUR); \
result=((offset)!=(off_t)-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_SEEK_BEGIN|CURRENT|END
* Purpose : set file position relativ to begin/current/end
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_SEEK_BEGIN
#include <sys/types.h>
#include <unistd.h>
#define TARGET_NATIVE_FILE_SEEK_BEGIN(filedescriptor,offset,newoffset,result) \
do { \
newoffset=lseek(filedescriptor,offset,SEEK_SET); \
result=((newoffset)!=(off_t)-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
#ifndef TARGET_NATIVE_FILE_SEEK_CURRENT
#include <sys/types.h>
#include <unistd.h>
#define TARGET_NATIVE_FILE_SEEK_CURRENT(filedescriptor,offset,newoffset,result) \
do { \
newoffset=lseek(filedescriptor,offset,SEEK_CUR); \
result=((newoffset)!=(off_t)-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
#ifndef TARGET_NATIVE_FILE_SEEK_END
#include <sys/types.h>
#include <unistd.h>
#define TARGET_NATIVE_FILE_SEEK_END(filedescriptor,offset,newoffset,result) \
do { \
newoffset=lseek(filedescriptor,offset,SEEK_END); \
result=((newoffset)!=(off_t)-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_TRUNCATE
* Purpose : truncate a file
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_TRUNCATE
#include <unistd.h>
#define TARGET_NATIVE_FILE_TRUNCATE(filedescriptor,offset,result) \
do { \
result=(ftruncate(filedescriptor,offset)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_SIZE
* Purpose : get size of file (in bytes)
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_SIZE
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define TARGET_NATIVE_FILE_SIZE(filedescriptor,length,result) \
do { \
struct stat __statBuffer; \
\
result=(fstat(filedescriptor,&__statBuffer)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
length=TARGET_NATIVE_MATH_INT_INT32_TO_INT64(__statBuffer.st_size); \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_AVAILABLE
* Purpose : get available bytes for read
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_AVAILABLE
#ifdef HAVE_SYS_IOCTL_H
#define BSD_COMP /* Get FIONREAD on Solaris2 */
#include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_FILIO_H /* Get FIONREAD on Solaris 2.5 */
#include <sys/filio.h>
#endif
#if defined (FIONREAD)
#define TARGET_NATIVE_FILE_AVAILABLE(filedescriptor,length,result) \
do { \
ssize_t __n; \
\
result=(ioctl(filedescriptor,FIONREAD,(char*)&__n)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
length=TARGET_NATIVE_MATH_INT_INT32_TO_INT64(__n); \
} while (0)
#elif defined(HAVE_FSTAT)
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define TARGET_NATIVE_FILE_AVAILABLE(filedescriptor,length,result) \
do { \
struct stat __statBuffer; \
off_t __n; \
\
length=0; \
\
if ((fstat(filedescriptor,&__statBuffer)==0) && S_ISREG(__statBuffer.st_mode)) \
{ \
__n=(lseek(filedescriptor,0,SEEK_CUR)); \
if (__n!=-1) \
{ \
length=TARGET_NATIVE_MATH_INT_INT32_TO_INT64(__statBuffer.st_size-__n); \
result=TARGET_NATIVE_OK; \
} \
else \
{ \
result=TARGET_NATIVE_ERROR; \
} \
} \
else \
{ \
result=TARGET_NATIVE_ERROR; \
} \
} while (0)
#elif defined(HAVE_SELECT)
#include <string.h>
#include <sys/select.h>
#define TARGET_NATIVE_FILE_AVAILABLE(filedescriptor,length,result) \
do { \
fd_set __filedescriptset; \
struct timeval __timeval; \
\
length=0; \
\
FD_ZERO(&__filedescriptset); \
FD_SET(filedescriptor,&__filedescriptset); \
memset(&__timeval,0,sizeof(__timeval)); \
switch (select(filedescriptor+1,&__filedescriptset,NULL,NULL,&__timeval)==0) \
{ \
case -1: result=TARGET_NATIVE_ERROR; break; \
case 0: length=JNI_JLONG_CONST_0; result=TARGET_NATIVE_OK; break; \
default: length=JNI_JLONG_CONST_1; result=TARGET_NATIVE_OK; break; \
} \
} while (0)
#else
#define TARGET_NATIVE_FILE_AVAILABLE(filedescriptor,length,result) \
do { \
errno=TARGET_NATIVE_ERROR_OPERATION_NOT_PERMITTED; \
length=0; \
result=TARGET_NATIVE_ERROR; \
} while (0)
#endif
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_READ|WRITE
* Purpose : read/write from/to frile
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_READ
#include <unistd.h>
#define TARGET_NATIVE_FILE_READ(filedescriptor,buffer,length,bytesRead,result) \
do { \
bytesRead=read(filedescriptor,buffer,length); \
result=(bytesRead!=-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
#ifndef TARGET_NATIVE_FILE_WRITE
#include <unistd.h>
#define TARGET_NATIVE_FILE_WRITE(filedescriptor,buffer,length,bytesWritten,result) \
do { \
bytesWritten=write(filedescriptor,buffer,length); \
result=(bytesWritten!=-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_SET_MODE_READONLY
* Purpose : set file mode to read-only
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_SET_MODE_READONLY
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define TARGET_NATIVE_FILE_SET_MODE_READONLY(filename,result) \
do { \
struct stat __statBuffer; \
\
if (stat(filename,&__statBuffer)==0) { \
result=(chmod(filename,__statBuffer.st_mode & TARGET_NATIVE_FILE_FILEPERMISSION_READONLY)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} else { \
result=TARGET_NATIVE_ERROR; \
} \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_EXISTS
* Purpose : check if file exists
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_EXISTS
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define TARGET_NATIVE_FILE_EXISTS(filename,result) \
do { \
struct stat __statBuffer; \
\
result=(stat(filename,&__statBuffer)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_IS_FILE
* Purpose : check if directory entry is a file
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_IS_FILE
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define TARGET_NATIVE_FILE_IS_FILE(filename,result) \
do { \
struct stat __statBuffer; \
\
result=((stat(filename,&__statBuffer)==0) && (S_ISREG(__statBuffer.st_mode)))?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_IS_DIRECTORY
* Purpose : check if directory entry is a directory
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_IS_DIRECTORY
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define TARGET_NATIVE_FILE_IS_DIRECTORY(filename,result) \
do { \
struct stat __statBuffer; \
\
result=((stat(filename,&__statBuffer)==0) && (S_ISDIR(__statBuffer.st_mode)))?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_GET_LAST_MODIFIED
* Purpose : get last modification time of file (milliseconds)
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_GET_LAST_MODIFIED
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define TARGET_NATIVE_FILE_GET_LAST_MODIFIED(filename,time,result) \
do { \
struct stat __statBuffer; \
\
time=TARGET_NATIVE_MATH_INT_INT64_CONST_0; \
if (stat(filename,&__statBuffer)==0) { \
time=TARGET_NATIVE_MATH_INT_INT64_MUL(TARGET_NATIVE_MATH_INT_INT32_TO_INT64(__statBuffer.st_mtime), \
TARGET_NATIVE_MATH_INT_INT32_TO_INT64(1000) \
); \
result=TARGET_NATIVE_OK; \
} else { \
result=TARGET_NATIVE_ERROR; \
} \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_SET_LAST_MODIFIED
* Purpose : set last modification time of file (milliseconds)
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_SET_LAST_MODIFIED
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#ifdef HAVE_UTIME_H
#include <utime.h>
#elif HAVE_SYS_UTIME_H
#include <sys/utime.h>
#else
#error utime.h not found. Please check configuration.
#endif
#define TARGET_NATIVE_FILE_SET_LAST_MODIFIED(filename,time,result) \
do { \
struct stat __statBuffer; \
struct utimbuf __utimeBuffer; \
\
if (stat(filename,&__statBuffer)==0) { \
__utimeBuffer.actime =__statBuffer.st_atime; \
__utimeBuffer.modtime=TARGET_NATIVE_MATH_INT_INT64_TO_INT32(TARGET_NATIVE_MATH_INT_INT64_DIV(time, \
TARGET_NATIVE_MATH_INT_INT32_TO_INT64(1000) \
) \
); \
result=(utime(filename,&__utimeBuffer)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} else { \
result=TARGET_NATIVE_ERROR; \
} \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_DELETE
* Purpose : delete a file,link or directory
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_DELETE
#define TARGET_NATIVE_FILE_DELETE(filename,result) \
do { \
result=((unlink(filename)==0) || (rmdir(filename)==0))?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_RENAME
* Purpose : delete a file, link or directory
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_RENAME
#define TARGET_NATIVE_FILE_RENAME(oldfilename,newfilename,result) \
do { \
result=(rename(oldfilename,newfilename)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_MAKE_DIR
* Purpose : create new directory
* Input : name - directory name
* Output : result - 1 if successful, 0 otherwise
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_MAKE_DIR
#include <sys/stat.h>
#define TARGET_NATIVE_FILE_MAKE_DIR(name,result) \
do { \
result=((mkdir(name,(S_IRWXO|S_IRWXG|S_IRWXU))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR); \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_GET_CWD
* Purpose : get current working directory
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_GET_CWD
#include <unistd.h>
#define TARGET_NATIVE_FILE_GET_CWD(path,maxPathLength,result) \
do {\
result=(getcwd(path,maxPathLength)!=NULL)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_OPEN_DIR
* Purpose : open directory for reading entries.
* Input : -
* Output : handle - handle if not error, NULL otherwise
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_OPEN_DIR
#include <sys/types.h>
#include <dirent.h>
#define TARGET_NATIVE_FILE_OPEN_DIR(filename,handle,result) \
do { \
handle=(void*)opendir(filename); \
result=(handle!=NULL)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while(0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_CLOSE_DIR
* Purpose : close directory
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_CLOSE_DIR
#include <sys/types.h>
#include <dirent.h>
#define TARGET_NATIVE_FILE_CLOSE_DIR(handle,result) \
do { \
closedir((DIR*)handle); \
result=TARGET_NATIVE_OK; \
} while(0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_READ_DIR
* Purpose : read directory entry
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
/* XXX ??? name als buffer? */
#ifndef TARGET_NATIVE_FILE_READ_DIR
#include <sys/types.h>
#include <dirent.h>
#define TARGET_NATIVE_FILE_READ_DIR(handle,name,result) \
do { \
struct dirent *__direntBuffer; \
\
name=NULL; \
\
__direntBuffer=readdir((DIR*)handle); \
if (__direntBuffer!=NULL) { \
name=__direntBuffer->d_name; \
result=TARGET_NATIVE_OK; \
} else { \
result=TARGET_NATIVE_ERROR; \
} \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_FSYNC
* Purpose : do filesystem sync
* Input : -
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
#ifndef TARGET_NATIVE_FILE_FSYNC
#define TARGET_NATIVE_FILE_FSYNC(filedescriptor,result) \
do { \
result=(fsync(filedescriptor)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while(0)
#endif
/***************************** Functions *******************************/
#ifdef __cplusplus
}
#endif
#endif /* __TARGET_GENERIC_FILE__ */
/* end of file */
@@ -0,0 +1,82 @@
/* generic_math_int64.h - Native methods for 64bit math operations
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
/*
Description: generic target defintions of miscellaneous functions
Systems : all
*/
#ifndef __TARGET_GENERIC_IO__
#define __TARGET_GENERIC_IO__
/* check if target_native_io.h included */
#ifndef __TARGET_NATIVE_IO__
#error Do NOT INCLUDE generic target files! Include the corresponding native target files instead!
#endif
/****************************** Includes *******************************/
/* do not move; needed here because of some macro definitions */
#include "config.h"
#include <stdlib.h>
#include <assert.h>
#include "target_native.h"
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
/***************************** Datatypes *******************************/
/***************************** Variables *******************************/
/****************************** Macros *********************************/
/***************************** Functions *******************************/
#ifdef __cplusplus
extern "C"
#endif
#ifdef __cplusplus
}
#endif
#endif /* __TARGET_GENERIC_IO__ */
/* end of file */
@@ -0,0 +1,130 @@
/* generic_math_int64.h - Native methods for 64bit math operations
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
/*
Description: generic target defintions of float/double constants/
macros/functions
Systems : all
*/
#ifndef __TARGET_GENERIC_MATH_FLOAT__
#define __TARGET_GENERIC_MATH_FLOAT__
/* check if target_native_math_float.h included */
#ifndef __TARGET_NATIVE_MATH_FLOAT__
#error Do NOT INCLUDE generic target files! Include the corresponding native target files instead!
#endif
/****************************** Includes *******************************/
/* do not move; needed here because of some macro definitions */
#include "config.h"
#include <stdlib.h>
#include <assert.h>
#include <jni.h>
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
/***************************** Datatypes *******************************/
/***************************** Variables *******************************/
/****************************** Macros *********************************/
/* test float/double values for NaN,Inf */
#ifndef TARGET_NATIVE_MATH_FLOAT_FLOAT_ISNAN
#include <math.h>
#define TARGET_NATIVE_MATH_FLOAT_FLOAT_ISNAN(f) isnan(f)
#endif
#ifndef TARGET_NATIVE_MATH_FLOAT_FLOAT_ISINF
#include <math.h>
#define TARGET_NATIVE_MATH_FLOAT_FLOAT_ISINF(f) isinf(f)
#endif
#ifndef TARGET_NATIVE_MATH_FLOAT_FLOAT_FINITE
#include <math.h>
#define TARGET_NATIVE_MATH_FLOAT_FLOAT_FINITE(f) finite(f)
#endif
#ifndef TARGET_NATIVE_MATH_FLOAT_DOUBLE_ISNAN
#include <math.h>
#define TARGET_NATIVE_MATH_FLOAT_DOUBLE_ISNAN(d) isnan(d)
#endif
#ifndef TARGET_NATIVE_MATH_FLOAT_DOUBLE_ISINF
#include <math.h>
#define TARGET_NATIVE_MATH_FLOAT_DOUBLE_ISINF(d) isinf(d)
#endif
#ifndef TARGET_NATIVE_MATH_FLOAT_DOUBLE_FINITE
#include <math.h>
#define TARGET_NATIVE_MATH_FLOAT_DOUBLE_FINITE(d) finite(d)
#endif
/* division, modulo operations (used to avoid unexcepted exceptions on some
targets; generic codes are direct operations without checks)
*/
#ifndef TARGET_NATIVE_MATH_FLOAT_FLOAT_DIV
#define TARGET_NATIVE_MATH_FLOAT_FLOAT_DIV(f0,f1) ((f0)/(f1))
#endif
#ifndef TARGET_NATIVE_MATH_FLOAT_FLOAT_MOD
#include <math.h>
#define TARGET_NATIVE_MATH_FLOAT_FLOAT_MOD(f0,f1) ((jfloat)fmod((jdouble)(f0),(jdouble)(f1)))
#endif
#ifndef TARGET_NATIVE_MATH_FLOAT_DOUBLE_DIV
#define TARGET_NATIVE_MATH_FLOAT_DOUBLE_DIV(d0,d1) ((d0)/(d1))
#endif
#ifndef TARGET_NATIVE_MATH_FLOAT_DOUBLE_MOD
#include <math.h>
#define TARGET_NATIVE_MATH_FLOAT_DOUBLE_MOD(d0,d1) fmod(d0,d1)
#endif
/***************************** Functions *******************************/
#ifdef __cplusplus
extern "C"
#endif
#ifdef __cplusplus
}
#endif
#endif /* __TARGET_GENERIC_MATH_FLOAT__ */
/* end of file */
@@ -0,0 +1,260 @@
/* generic_math_int64.h - Native methods for 64bit math operations
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
/*
Description: generic target defintions of int/int64 constants/
macros/functions
Systems : all
*/
#ifndef __TARGET_GENERIC_MATH_INT__
#define __TARGET_GENERIC_MATH_INT__
/* check if target_native_math_int.h included */
#ifndef __TARGET_NATIVE_MATH_INT__
#error Do NOT INCLUDE generic target files! Include the corresponding native target files instead!
#endif
/****************************** Includes *******************************/
/* do not move; needed here because of some macro definitions */
#include "config.h"
#include <stdlib.h>
#include <assert.h>
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
#ifndef TARGET_NATIVE_MATH_INT_INT64_CONST_0
#define TARGET_NATIVE_MATH_INT_INT64_CONST_0 0LL
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_CONST_1
#define TARGET_NATIVE_MATH_INT_INT64_CONST_1 1LL
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_CONST_MINUS_1
#define TARGET_NATIVE_MATH_INT_INT64_CONST_MINUS_1 -1LL
#endif
/***************************** Datatypes *******************************/
/***************************** Variables *******************************/
/****************************** Macros *********************************/
/* math operations */
#ifndef TARGET_NATIVE_MATH_INT_INT64_ADD
#define TARGET_NATIVE_MATH_INT_INT64_ADD(v1,v2) ((v1)+(v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_SUB
#define TARGET_NATIVE_MATH_INT_INT64_SUB(v1,v2) ((v1)-(v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_MUL
#define TARGET_NATIVE_MATH_INT_INT64_MUL(v1,v2) ((v1)*(v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_DIV
#define TARGET_NATIVE_MATH_INT_INT64_DIV(v1,v2) ((v1)/(v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_MOD
#define TARGET_NATIVE_MATH_INT_INT64_MOD(v1,v2) ((v1)%(v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_ADD
#define TARGET_NATIVE_MATH_INT_UINT64_ADD(v1,v2) ((v1)+(v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_SUB
#define TARGET_NATIVE_MATH_INT_UINT64_SUB(v1,v2) ((v1)-(v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_MUL
#define TARGET_NATIVE_MATH_INT_UINT64_MUL(v1,v2) ((v1)*(v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_DIV
#define TARGET_NATIVE_MATH_INT_UINT64_DIV(v1,v2) ((v1)/(v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_MOD
#define TARGET_NATIVE_MATH_INT_UINT64_MOD(v1,v2) ((v1)%(v2))
#endif
/* bit operations */
#ifndef TARGET_NATIVE_MATH_INT_INT64_AND
#define TARGET_NATIVE_MATH_INT_INT64_AND(v1,v2) ((v1)&(v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_OR
#define TARGET_NATIVE_MATH_INT_INT64_OR(v1,v2) ((v1)|(v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_XOR
#define TARGET_NATIVE_MATH_INT_INT64_XOR(v1,v2) ((v1)^(v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_AND
#define TARGET_NATIVE_MATH_INT_UINT64_AND(v1,v2) ((v1)&(v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_OR
#define TARGET_NATIVE_MATH_INT_UINT64_OR(v1,v2) ((v1)|(v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_XOR
#define TARGET_NATIVE_MATH_INT_UINT64_XOR(v1,v2) ((v1)^(v2))
#endif
/* shift operations */
#ifndef TARGET_NATIVE_MATH_INT_INT64_SHIFTL
#define TARGET_NATIVE_MATH_INT_INT64_SHIFTL(v,l) ((v)<<(l))
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_SHIFTR
#define TARGET_NATIVE_MATH_INT_INT64_SHIFTR(v,l) (((v)>>(l)) | (((v)>=0) ? 0 : (0xffffFFFFffffFFFFLL << (64-(l)))))
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_SHIFTR
#define TARGET_NATIVE_MATH_INT_UINT64_SHIFTR(v,l) (((v)>>(l)) & ~(((v)>=0) ? 0 : (0xffffFFFFffffFFFFLL << (64-(l)))))
#endif
/* negation */
#ifndef TARGET_NATIVE_MATH_INT_INT64_NEG
#define TARGET_NATIVE_MATH_INT_INT64_NEG(v) (-(v))
#endif
/* increment/decrement routines */
#ifndef TARGET_NATIVE_MATH_INT_INT64_INC
#define TARGET_NATIVE_MATH_INT_INT64_INC(v) { v++; }
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_DEC
#define TARGET_NATIVE_MATH_INT_INT64_DEC(v) { v--; }
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_INC
#define TARGET_NATIVE_MATH_INT_UINT64_INC(v) { v++; }
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_DEC
#define TARGET_NATIVE_MATH_INT_UINT64_DEC(v) { v--; }
#endif
/* comparison routines */
#ifndef TARGET_NATIVE_MATH_INT_INT64_EQ
#define TARGET_NATIVE_MATH_INT_INT64_EQ(v1,v2) ((v1) == (v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_NE
#define TARGET_NATIVE_MATH_INT_INT64_NE(v1,v2) ((v1) != (v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_LT
#define TARGET_NATIVE_MATH_INT_INT64_LT(v1,v2) ((v1) < (v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_LE
#define TARGET_NATIVE_MATH_INT_INT64_LE(v1,v2) ((v1) <= (v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_GT
#define TARGET_NATIVE_MATH_INT_INT64_GT(v1,v2) ((v1) > (v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_GE
#define TARGET_NATIVE_MATH_INT_INT64_GE(v1,v2) ((v1) >= (v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_EQ
#define TARGET_NATIVE_MATH_INT_UINT64_EQ(v1,v2) ((v1) == (v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_NE
#define TARGET_NATIVE_MATH_INT_UINT64_NE(v1,v2) ((v1) != (v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_LT
#define TARGET_NATIVE_MATH_INT_UINT64_LT(v1,v2) ((v1) < (v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_LE
#define TARGET_NATIVE_MATH_INT_UINT64_LE(v1,v2) ((v1) <= (v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_GT
#define TARGET_NATIVE_MATH_INT_UINT64_GT(v1,v2) ((v1) > (v2))
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_GE
#define TARGET_NATIVE_MATH_INT_UINT64_GE(v1,v2) ((v1) >= (v2))
#endif
/* type conversion routines */
#ifndef TARGET_NATIVE_MATH_INT_INT32_TO_INT64
#define TARGET_NATIVE_MATH_INT_INT32_TO_INT64(v) ((jlong)(v))
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT32_TO_UINT64
#define TARGET_NATIVE_MATH_INT_UINT32_TO_UINT64(v) ((jlong)(v))
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_TO_INT32
#define TARGET_NATIVE_MATH_INT_INT64_TO_INT32(v) ((jint )(v))
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_TO_UINT32
#define TARGET_NATIVE_MATH_INT_UINT64_TO_UINT32(v) ((jint)(v))
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_TO_DOUBLE
#define TARGET_NATIVE_MATH_INT_INT64_TO_DOUBLE(v) ((jdouble)(v))
#endif
/* combine/split int32 low/high values <-> int64 values */
#ifndef TARGET_NATIVE_MATH_INT_INT32_LOW_HIGH_TO_INT64
#define TARGET_NATIVE_MATH_INT_INT32_LOW_HIGH_TO_INT64(low,high,v) \
do { \
(v)=((((jlong)(high)) << 32) | ((((jlong)(low)) << 0) & 0x00000000ffffFFFFLL)); \
} while (0)
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT32_LOW_HIGH_TO_UINT64
#define TARGET_NATIVE_MATH_INT_UINT32_LOW_HIGH_TO_UINT64(low,high,v) \
do { \
(v)=((((jlong)(high)) << 32) | ((((jlong)(low)) << 0) & 0x00000000ffffFFFFLL)); \
} while (0)
#endif
#ifndef TARGET_NATIVE_MATH_INT_INT64_TO_INT32_LOW_HIGH
#define TARGET_NATIVE_MATH_INT_INT64_TO_INT32_LOW_HIGH(v,low,high) \
do { \
(high)=((v) & 0xFFFFffff00000000L) >> 32; \
(low) =((v) & 0x00000000FFFFffffL) >> 0; \
} while (0)
#endif
#ifndef TARGET_NATIVE_MATH_INT_UINT64_TO_UINT32_LOW_HIGH
#define TARGET_NATIVE_MATH_INT_UINT64_TO_UINT32_LOW_HIGH(v,low,high) \
do { \
(high)=((v) & 0xFFFFffff00000000L) >> 32; \
(low) =((v) & 0x00000000FFFFffffL) >> 0; \
} while (0)
#endif
/***************************** Functions *******************************/
#ifdef __cplusplus
extern "C"
#endif
#ifdef __cplusplus
}
#endif
#endif /* __TARGET_GENERIC_MATH_INT__ */
/* end of file */
@@ -0,0 +1,203 @@
/* generic_math_int64.h - Native methods for 64bit math operations
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
/*
Description: generic target defintions of miscellaneous functions
Systems : all
*/
#ifndef __TARGET_GENERIC_MISC__
#define __TARGET_GENERIC_MISC__
/* check if target_native_misc.h included */
#ifndef __TARGET_NATIVE_MISC__
#error Do NOT INCLUDE generic target files! Include the corresponding native target files instead!
#endif
/****************************** Includes *******************************/
/* do not move; needed here because of some macro definitions */
#include "config.h"
#include <stdlib.h>
#include <assert.h>
#include "target_native.h"
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
/***************************** Datatypes *******************************/
/***************************** Variables *******************************/
/****************************** Macros *********************************/
/***********************************************************************\
* Name : TARGET_NATIVE_MISC_FORMAT_STRING<n>
* Purpose : format a string (with a fixed number of) arguments
* Input : buffer - buffer for string
* bufferSize - size of buffer
* format - format string (like printf)
* args - optional arguments (GNU CPP only!)
* Output : -
* Return : -
* Side-effect: unknown
* Notes : - this is a "safe" macro to format string; buffer-
* overflows will be avoided. Direct usage of e. g.
* snprintf() is not permitted because it is not ANSI C
* (not portable!)
* - do not use this routine in a function without
* variable number of arguments (ellipses), because
* va_list/va_start/va_end is used!
\***********************************************************************/
#ifndef TARGET_NATIVE_MISC_FORMAT_STRING0
#include <stdarg.h>
#define TARGET_NATIVE_MISC_FORMAT_STRING0(buffer,bufferSize,format) \
do { \
snprintf(buffer,bufferSize,format); \
} while (0)
#endif
#ifndef TARGET_NATIVE_MISC_FORMAT_STRING1
#include <stdarg.h>
#define TARGET_NATIVE_MISC_FORMAT_STRING1(buffer,bufferSize,format,arg1) \
do { \
snprintf(buffer,bufferSize,format,arg1); \
} while (0)
#endif
#ifndef TARGET_NATIVE_MISC_FORMAT_STRING2
#include <stdarg.h>
#define TARGET_NATIVE_MISC_FORMAT_STRING2(buffer,bufferSize,format,arg1,arg2) \
do { \
snprintf(buffer,bufferSize,format,arg1,arg2); \
} while (0)
#endif
#ifndef TARGET_NATIVE_MISC_FORMAT_STRING3
#include <stdarg.h>
#define TARGET_NATIVE_MISC_FORMAT_STRING3(buffer,bufferSize,format,arg1,arg2,arg3) \
do { \
snprintf(buffer,bufferSize,format,arg1,arg2,arg3); \
} while (0)
#endif
#ifndef TARGET_NATIVE_MISC_FORMAT_STRING4
#include <stdarg.h>
#define TARGET_NATIVE_MISC_FORMAT_STRING4(buffer,bufferSize,format,arg1,arg2,arg3,arg4) \
do { \
snprintf(buffer,bufferSize,format,arg1,arg2,arg3,arg4); \
} while (0)
#endif
#ifndef TARGET_NATIVE_MISC_FORMAT_STRING5
#include <stdarg.h>
#define TARGET_NATIVE_MISC_FORMAT_STRING5(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5) \
do { \
snprintf(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5); \
} while (0)
#endif
#ifndef TARGET_NATIVE_MISC_FORMAT_STRING6
#include <stdarg.h>
#define TARGET_NATIVE_MISC_FORMAT_STRING6(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5,arg6) \
do { \
snprintf(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5,arg6); \
} while (0)
#endif
#ifndef TARGET_NATIVE_MISC_FORMAT_STRING7
#include <stdarg.h>
#define TARGET_NATIVE_MISC_FORMAT_STRING7(buffer,bufferSize,format,arg1,arg2,arg3,arg14,arg5,arg6,arg7) \
do { \
snprintf(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5,arg6,arg7); \
} while (0)
#endif
#ifndef TARGET_NATIVE_MISC_FORMAT_STRING8
#include <stdarg.h>
#define TARGET_NATIVE_MISC_FORMAT_STRING8(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) \
do { \
snprintf(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); \
} while (0)
#endif
#ifndef TARGET_NATIVE_MISC_FORMAT_STRING9
#include <stdarg.h>
#define TARGET_NATIVE_MISC_FORMAT_STRING9(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9) \
do { \
snprintf(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); \
} while (0)
#endif
/***********************************************************************\
* Name : TARGET_NATIVE_FORMAT_STRING_ELLIPSE
* Purpose : format a string with arguments
* Input : buffer - buffer for string
* bufferSize - size of buffer
* format - format string (like printf)
* Output : -
* Return : -
* Side-effect: unknown
* Notes : - this is a "safe" macro to format string; buffer-
* overflows will be avoided. Direct usage of e. g.
* snprintf() is not permitted because it is not ANSI C
* (not portable!)
* - do not use this routine in a function without
* variable number of arguments (ellipses), because
* va_list/va_start/va_end is used!
\***********************************************************************/
#ifndef TARGET_NATIVE_MISC_FORMAT_STRING_ELLIPSE
#include <stdarg.h>
#define TARGET_NATIVE_FORMAT_STRING_ELLIPSE(buffer,bufferSize,format) \
do { \
va_list __arguments; \
\
va_start(__arguments,format); \
vsnprintf(buffer,bufferSize,format,__arguments); \
va_end(__arguments); \
} while (0)
#endif
/***************************** Functions *******************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* __TARGET_GENERIC_MISC__ */
/* end of file */
File diff suppressed because it is too large Load Diff
+149
View File
@@ -0,0 +1,149 @@
The GNU classpath native layer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To enable GNU classpath to run on a diverse array of different hardware
platforms, a new native software layer has been added. This layer hide all
machine and hardware dependent issues except common available definitions,
which are ANSI C functions. For each targets system where the GNU classpath
library is to be used, a specific set of native layer functions have to be
provided. A generic set of functions is provided for Unix like systems
(currently tested only with Linux). For a new target system, some or
all native layer functions have to be rewritten. The following scheme
illustrate the native layer.
Java API
----------------------
| Java classes |
| -------------------- |
| C native functions |
| -------------------- |
>> | C native layer | <<
| -------------------- |
| operating system |
| -------------------- |
| hardware |
----------------------
The C native layer is implemented as a set of C pre-processor native macros.
These macros expand to the appropriated native code. Macros are used
instead function calls to give optimal performance and small code size.
Of course in special cases, a macro can also expand to a function call
if this is needed. This approach provide a flexible and efficient
implementation of the native layer.
The naming pattern for native macros is like follows:
TARGET_NATIVE_<module name>_<macro name>
where <module name> is a name of a module, e. g. FILE; <macro name> is
the name of the specific native macro, e. g. OPEN_READ.
The parameters for the macro use in general (with a few exceptions) the
scheme
<parameter>,<parameter>,...,<result>
where <parameter> is input/output parameter and <result> is the result
code TARGET_NATIVE_OK or TARGET_NATIVE_ERROR. Specific error codes
and error strings can be gotten with
TARGET_NATIVE_LAST_ERROR and
TARGET_NATIVE_LAST_ERROR_STRING
(see also file target_generic.h).
For a single target system there exists two sets of native macros in
the files
a) <target name>/target_native_<module name>.h
b) generic/target_generic_<module name>.h
The macros in "a" are target specific implementations of native
functions, the macros in "b" are generic implementations (for Unix) of
the same native functions. If a native macro is not defined in the file
"a", then the definition in file "b" is used (there is a check to see if
a native macros is already defined elsewhere). This technique enables
"a" to 'overwrite' single generic native macros with specific native
macros for a specific target. In the default case, where only the
generic implementation of the native macros is used, the files in the
directory '<target name>' are empty except for the mandatory include of the
generic header file in the directory 'generic' at the end. Please
look at the existing Linux target specific files.
The directory and file structure is as follows.
native
...
|
|--- target
| |
| |--- Linux
| | |--- target_native_<module name>.h
| | |--- ...
| | ...
| |--- ...
| |--- generic
| | |--- target_generic_<module name>.h
| | |--- ...
... ... ...
Include hierarchy is as follows.
native file <name>
--> include 'target_native_<module name>.h'
...
<target specific definitions>
...
--> include 'target_generic_<module name>.h'
...
<generic definitions>
...
When writing native code, please take care with the following.
- Use _only_ ANSI C specific functions directly which are available
on all target systems with the same parameters, e. g. strdup() is
not an ANSI C function, thus is is not available on all systems; mkdir()
expect on some systems different parameters.
!!!Do NOT use this functions in your native code!!!
Instead
* if a function is not available, create a native macro in the file
<target name>/target_native_<module name>.h
* if it is a generic function, include a generic implementation in
generic/target_generic_<module name>.h
* Then use this macro in your native code.
- Avoid _all_ OS specific data types and constants, e. g. structures or error
numbers. Instead, wrap them in a native macro and convert the values to
basic scalar types like char, int, double or long.
- Take care with 64 bit values; the are machine dependent. Not all
target system support 64 bit operations. The macros in
target_generic_math_int.h give a set of macros implementing 64 bit
operations and constants.
- Avoid - if possible - non-reentrant functions. Non-reentrant functions
cause strange problems on some multitasking systems.
- Avoid - if possible - dynamic data types created by malloc() and similar
functions. Instead use (local) static variables to avoid stack usage.
On some target systems, dynamic memory management is either slow or even
dangerous. Moreover malloc()-calls can cause fragmentation of the system
memory, which could result in a system crash or an application failure.
For some examples, please look in the current implementation for
Linux in the directory 'target/Linux' and the generic implementation in
the directory 'target/generic'.
aicas GmbH, February 2003