diff options
author | Tom Tromey <tromey@gcc.gnu.org> | 2005-07-16 00:30:23 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2005-07-16 00:30:23 +0000 |
commit | f911ba985aa7fe0096c386c5be385ac5825ea527 (patch) | |
tree | a0b991cf5866ae1d616639b906ac001811d74508 /libjava/classpath/native/target | |
parent | 6f4434b39b261de5317dc81ddfdd94d2e1d62b11 (diff) | |
download | gcc-f911ba985aa7fe0096c386c5be385ac5825ea527.zip gcc-f911ba985aa7fe0096c386c5be385ac5825ea527.tar.gz gcc-f911ba985aa7fe0096c386c5be385ac5825ea527.tar.bz2 |
Initial revision
From-SVN: r102074
Diffstat (limited to 'libjava/classpath/native/target')
21 files changed, 3720 insertions, 0 deletions
diff --git a/libjava/classpath/native/target/.cvsignore b/libjava/classpath/native/target/.cvsignore new file mode 100644 index 0000000..e9f2658 --- /dev/null +++ b/libjava/classpath/native/target/.cvsignore @@ -0,0 +1,8 @@ +*.o +*.a +*.lo +*.la +.libs +.deps +Makefile +Makefile.in diff --git a/libjava/classpath/native/target/Linux/.cvsignore b/libjava/classpath/native/target/Linux/.cvsignore new file mode 100644 index 0000000..e9f2658 --- /dev/null +++ b/libjava/classpath/native/target/Linux/.cvsignore @@ -0,0 +1,8 @@ +*.o +*.a +*.lo +*.la +.libs +.deps +Makefile +Makefile.in diff --git a/libjava/classpath/native/target/Linux/Makefile.am b/libjava/classpath/native/target/Linux/Makefile.am new file mode 100644 index 0000000..bd267dc --- /dev/null +++ b/libjava/classpath/native/target/Linux/Makefile.am @@ -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 diff --git a/libjava/classpath/native/target/Linux/target_native.h b/libjava/classpath/native/target/Linux/target_native.h new file mode 100644 index 0000000..4e1d513 --- /dev/null +++ b/libjava/classpath/native/target/Linux/target_native.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 */ + diff --git a/libjava/classpath/native/target/Linux/target_native_file.h b/libjava/classpath/native/target/Linux/target_native_file.h new file mode 100644 index 0000000..0c40b44 --- /dev/null +++ b/libjava/classpath/native/target/Linux/target_native_file.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 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 */ + diff --git a/libjava/classpath/native/target/Linux/target_native_io.h b/libjava/classpath/native/target/Linux/target_native_io.h new file mode 100644 index 0000000..03f43ad --- /dev/null +++ b/libjava/classpath/native/target/Linux/target_native_io.h @@ -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 */ diff --git a/libjava/classpath/native/target/Linux/target_native_math_float.h b/libjava/classpath/native/target/Linux/target_native_math_float.h new file mode 100644 index 0000000..0f3455d --- /dev/null +++ b/libjava/classpath/native/target/Linux/target_native_math_float.h @@ -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 */ + diff --git a/libjava/classpath/native/target/Linux/target_native_math_int.h b/libjava/classpath/native/target/Linux/target_native_math_int.h new file mode 100644 index 0000000..4c5fc67 --- /dev/null +++ b/libjava/classpath/native/target/Linux/target_native_math_int.h @@ -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 */ + diff --git a/libjava/classpath/native/target/Linux/target_native_misc.h b/libjava/classpath/native/target/Linux/target_native_misc.h new file mode 100644 index 0000000..00bc7ac --- /dev/null +++ b/libjava/classpath/native/target/Linux/target_native_misc.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 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 */ + diff --git a/libjava/classpath/native/target/Linux/target_native_network.h b/libjava/classpath/native/target/Linux/target_native_network.h new file mode 100644 index 0000000..23f9d0a --- /dev/null +++ b/libjava/classpath/native/target/Linux/target_native_network.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 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 */ + diff --git a/libjava/classpath/native/target/Makefile.am b/libjava/classpath/native/target/Makefile.am new file mode 100644 index 0000000..ba0ad79 --- /dev/null +++ b/libjava/classpath/native/target/Makefile.am @@ -0,0 +1,5 @@ +## Input file for automake to generate the Makefile.in used by configure + +SUBDIRS = Linux generic + +EXTRA_DIST = readme.txt diff --git a/libjava/classpath/native/target/generic/.cvsignore b/libjava/classpath/native/target/generic/.cvsignore new file mode 100644 index 0000000..e9f2658 --- /dev/null +++ b/libjava/classpath/native/target/generic/.cvsignore @@ -0,0 +1,8 @@ +*.o +*.a +*.lo +*.la +.libs +.deps +Makefile +Makefile.in diff --git a/libjava/classpath/native/target/generic/Makefile.am b/libjava/classpath/native/target/generic/Makefile.am new file mode 100644 index 0000000..bc8413c --- /dev/null +++ b/libjava/classpath/native/target/generic/Makefile.am @@ -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 diff --git a/libjava/classpath/native/target/generic/target_generic.h b/libjava/classpath/native/target/generic/target_generic.h new file mode 100644 index 0000000..e4ddf5c --- /dev/null +++ b/libjava/classpath/native/target/generic/target_generic.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 */ + diff --git a/libjava/classpath/native/target/generic/target_generic_file.h b/libjava/classpath/native/target/generic/target_generic_file.h new file mode 100644 index 0000000..cd90e73 --- /dev/null +++ b/libjava/classpath/native/target/generic/target_generic_file.h @@ -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 */ + diff --git a/libjava/classpath/native/target/generic/target_generic_io.h b/libjava/classpath/native/target/generic/target_generic_io.h new file mode 100644 index 0000000..cc24915 --- /dev/null +++ b/libjava/classpath/native/target/generic/target_generic_io.h @@ -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 */ diff --git a/libjava/classpath/native/target/generic/target_generic_math_float.h b/libjava/classpath/native/target/generic/target_generic_math_float.h new file mode 100644 index 0000000..e2085e0 --- /dev/null +++ b/libjava/classpath/native/target/generic/target_generic_math_float.h @@ -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 */ + diff --git a/libjava/classpath/native/target/generic/target_generic_math_int.h b/libjava/classpath/native/target/generic/target_generic_math_int.h new file mode 100644 index 0000000..c686148 --- /dev/null +++ b/libjava/classpath/native/target/generic/target_generic_math_int.h @@ -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 */ + diff --git a/libjava/classpath/native/target/generic/target_generic_misc.h b/libjava/classpath/native/target/generic/target_generic_misc.h new file mode 100644 index 0000000..1174aa8 --- /dev/null +++ b/libjava/classpath/native/target/generic/target_generic_misc.h @@ -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 */ + diff --git a/libjava/classpath/native/target/generic/target_generic_network.h b/libjava/classpath/native/target/generic/target_generic_network.h new file mode 100644 index 0000000..dbbd92e --- /dev/null +++ b/libjava/classpath/native/target/generic/target_generic_network.h @@ -0,0 +1,1278 @@ +/* target_generic_network.h - Native methods for network operations. + Copyright (C) 1998, 2004, 2005 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 network functions +Systems : all +*/ + +#ifndef __TARGET_GENERIC_NETWORK__ +#define __TARGET_GENERIC_NETWORK__ + +/* check if target_native_network.h included */ +#ifndef __TARGET_NATIVE_NETWORK__ + #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 "target_native.h" + +/****************** Conditional compilation switches *******************/ + +/***************************** Constants *******************************/ + +/***************************** Datatypes *******************************/ + +/***************************** Variables *******************************/ + +/****************************** Macros *********************************/ + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_IPADDRESS_BYTES_TO_INT +* Purpose : convert IP adddress (4 parts) into integer (host-format +* 32bit) +* Input : n0,n1,n2,n3 - IP address parts +* Output : i - integer with IP address in host-format +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_IPADDRESS_BYTES_TO_INT + #define TARGET_NATIVE_NETWORK_IPADDRESS_BYTES_TO_INT(n0,n1,n2,n3,i) \ + do { \ + i=(((unsigned char)n0) << 24) | \ + (((unsigned char)n1) << 16) | \ + (((unsigned char)n2) << 8) | \ + (((unsigned char)n3) << 0); \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_INT_TO_IPADDRESS_BYTES +* Purpose : convert IP adddress (4 parts) into integer (host-format +* 32bit) +* Input : n0,n1,n2,n3 - IP address parts +* Output : i - integer with IP address in host-format +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_INT_TO_IPADDRESS_BYTES + #define TARGET_NATIVE_NETWORK_INT_TO_IPADDRESS_BYTES(i,n0,n1,n2,n3) \ + do { \ + n0=(i & 0xFF000000) >> 24; \ + n1=(i & 0x00FF0000) >> 16; \ + n2=(i & 0x0000FF00) >> 8; \ + n3=(i & 0x000000FF) >> 0; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_GET_HOSTNAME +* Purpose : get hostname +* Input : maxNameLen - max. length of name +* Output : name - name (NUL terminated) +* result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_GET_HOSTNAME + #include <unistd.h> + #define TARGET_NATIVE_NETWORK_GET_HOSTNAME(name,maxNameLen,result) \ + do { \ + result=(gethostname(name,maxNameLen-1)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + name[maxNameLen-1]='\0'; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_GET_HOSTNAME_BY_ADDRESS +* Purpose : get hostname by address +* Input : address - IP address (32bit, NOT network byte order!) +* maxNameLen - max. length of name +* Output : name - name (NUL terminated) +* result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +/* XXX NYI??? reentrant? */ +#ifndef TARGET_NATIVE_NETWORK_GET_HOSTNAME_BY_ADDRESS + #include <netdb.h> + #define TARGET_NATIVE_NETWORK_GET_HOSTNAME_BY_ADDRESS(address,name,maxNameLen,result) \ + do { \ + int __networkAddress; \ + struct hostent *__hostEntry; \ + \ + __networkAddress=htonl(address); \ + __hostEntry = gethostbyaddr((char*)&__networkAddress,sizeof(__networkAddress),AF_INET); \ + if (__hostEntry!=NULL) \ + { \ + strncpy(name,__hostEntry->h_name,maxNameLen-1); \ + name[maxNameLen]='\0'; \ + result=TARGET_NATIVE_OK; \ + } \ + else \ + { \ + result=TARGET_NATIVE_ERROR; \ + } \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_GET_HOSTNAME_BY_NAME +* Purpose : get hostname by name +* Input : name - hostname +* maxAddressSize - max. size of address array +* Output : addresses - host adddresses (array, NOT in network +* byte order!) +* addressCount - number of entries in address array +* result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +/* XXX NYI??? reentrant? */ +#ifndef TARGET_NATIVE_NETWORK_GET_HOSTNAME_BY_NAME + #include <netdb.h> + #define TARGET_NATIVE_NETWORK_GET_HOSTNAME_BY_NAME(name,addresses,maxAddressSize,addressCount,result) \ + do { \ + struct hostent *__hostEntry; \ + \ + addressCount=0; \ + \ + __hostEntry = gethostbyname(name); \ + if (__hostEntry!=NULL) \ + { \ + while ((addressCount<maxAddressSize) && (__hostEntry->h_addr_list[addressCount]!=NULL)) \ + { \ + addresses[addressCount]=ntohl(*(int*)(__hostEntry->h_addr_list[addressCount])); \ + addressCount++; \ + } \ + result=TARGET_NATIVE_OK; \ + } \ + else \ + { \ + result=TARGET_NATIVE_ERROR; \ + } \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_OPEN_STREAM +* Purpose : open stream socket +* Input : - +* Output : socketDescriptor - socket descriptor +* result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_OPEN_STREAM + #include <sys/types.h> + #include <sys/socket.h> + #include <fcntl.h> + #define TARGET_NATIVE_NETWORK_SOCKET_OPEN_STREAM(socketDescriptor,result) \ + do { \ + socketDescriptor=socket(AF_INET,SOCK_STREAM,0); \ + fcntl(socketDescriptor,F_SETFD,FD_CLOEXEC); \ + result=(socketDescriptor!=-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_OPEN_DATAGRAM +* Purpose : open datagram socket +* Input : - +* Output : socketDescriptor - socket descriptor +* result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_OPEN_DATAGRAM + #include <sys/types.h> + #include <sys/socket.h> + #include <fcntl.h> + #define TARGET_NATIVE_NETWORK_SOCKET_OPEN_DATAGRAM(socketDescriptor,result) \ + do { \ + socketDescriptor=socket(AF_INET,SOCK_DGRAM,0); \ + fcntl(socketDescriptor,F_SETFD,FD_CLOEXEC); \ + result=(socketDescriptor!=-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_CLOSE +* Purpose : close socket +* Input : socketDescriptor - socket descriptor +* Output : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_CLOSE + #include <unistd.h> + #define TARGET_NATIVE_NETWORK_SOCKET_CLOSE(socketDescriptor,result) \ + do { \ + result=(close(socketDescriptor)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_CONNECT +* Purpose : connect socket +* Input : socketDescriptor - socket descriptor +* address - address (network format???) +* port - port number (NOT in network byte order!) +* Output : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_CONNECT + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_CONNECT(socketDescriptor,address,port,result) \ + do { \ + struct sockaddr_in __socketAddress; \ + \ + memset(&__socketAddress,0,sizeof(__socketAddress)); \ + __socketAddress.sin_family = AF_INET; \ + __socketAddress.sin_addr.s_addr = htonl(address); \ + __socketAddress.sin_port = htons(((short)port)); \ + \ + result=(connect(socketDescriptor,(struct sockaddr*)&__socketAddress,sizeof(__socketAddress))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_BIND +* Purpose : bind socket +* Input : socketDescriptor - socket descriptor +* address - address (NOT ??? in network byte order!) +* port - port (NOT in network byte order!) +* Output : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +/* XXX ??? address in network byte order? */ +#ifndef TARGET_NATIVE_NETWORK_SOCKET_BIND + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_BIND(socketDescriptor,address,port,result) \ + do { \ + struct sockaddr_in __socketAddress; \ + \ + memset(&__socketAddress,0,sizeof(__socketAddress)); \ + __socketAddress.sin_family = AF_INET; \ + __socketAddress.sin_addr.s_addr = htonl(address); \ + __socketAddress.sin_port = htons(((short)port)); \ + \ + result=(bind(socketDescriptor,(struct sockaddr*)&__socketAddress,sizeof(__socketAddress))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_LISTEN +* Purpose : listen socket +* Input : socketDescriptor - socket descriptor +* maxQueueLength - max. number of pending connections +* Output : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +/* XXX ??? address in network byte order? */ +#ifndef TARGET_NATIVE_NETWORK_SOCKET_LISTEN + #include <sys/socket.h> + #define TARGET_NATIVE_NETWORK_SOCKET_LISTEN(socketDescriptor,maxQueueLength,result) \ + do { \ + result=(listen(socketDescriptor,maxQueueLength)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_ACCEPT +* Purpose : accept socket +* Input : socketDescriptor - socket descriptor +* Output : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +/* XXX ??? address in network byte order? */ +#ifndef TARGET_NATIVE_NETWORK_SOCKET_ACCEPT + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_ACCEPT(socketDescriptor,newSocketDescriptor,result) \ + do { \ + struct sockaddr_in __socketAddress; \ + socklen_t __socketAddressLength; \ + \ + memset(&__socketAddress,0,sizeof(__socketAddress)); \ + __socketAddressLength=sizeof(__socketAddress); \ + newSocketDescriptor=accept(socketDescriptor,(struct sockaddr*)&__socketAddress,&__socketAddressLength); \ + result=(newSocketDescriptor!=-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_LOCAL_INFO +* Purpose : get local socket data info +* Input : socketDescriptor - socket descriptor +* Output : localAddress - local address (NOT in network byte order!) +* localPort - local port number (NOT in network byte order!) +* result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_LOCAL_INFO + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_GET_LOCAL_INFO(socketDescriptor,localAddress,localPort,result) \ + do { \ + struct sockaddr_in __socketAddress; \ + socklen_t __socketAddressLength; \ + \ + localAddress=0; \ + localPort =0; \ + \ + __socketAddressLength=sizeof(__socketAddress); \ + result=(getsockname(socketDescriptor,(struct sockaddr*)&__socketAddress,&__socketAddressLength)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + if (result==TARGET_NATIVE_OK) \ + { \ + localAddress=ntohl(__socketAddress.sin_addr.s_addr); \ + localPort =ntohs(__socketAddress.sin_port); \ + } \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_REMOTE_INFO +* Purpose : get remote socket data info +* Input : socketDescriptor - socket descriptor +* Output : remoteAddress - remote address (NOT in network byte order!) +* remotePort - remote port number (NOT in network byte order!) +* : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_REMOTE_INFO + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_GET_REMOTE_INFO(socketDescriptor,remoteAddress,remotePort,result) \ + do { \ + struct sockaddr_in __socketAddress; \ + socklen_t __socketAddressLength; \ + \ + remoteAddress=0; \ + remotePort =0; \ + \ + __socketAddressLength=sizeof(__socketAddress); \ + result=(getpeername(socketDescriptor,(struct sockaddr*)&__socketAddress,&__socketAddressLength)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + if (result==TARGET_NATIVE_OK) \ + { \ + remoteAddress=ntohl(__socketAddress.sin_addr.s_addr); \ + remotePort =ntohs(__socketAddress.sin_port); \ + } \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_AVAILABLE +* Purpose : get number of available bytes for receive +* Input : socketDescriptor - socket descriptor +* Output : bytesAvailable - available bytes for receive +* : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_AVAILABLE + #include <sys/ioctl.h> + #define TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_AVAILABLE(socketDescriptor,bytesAvailable,result) \ + do { \ + int __value; \ + \ + bytesAvailable=0; \ + \ + result=(ioctl(socketDescriptor,FIONREAD,&__value)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + if (result==TARGET_NATIVE_OK) \ + { \ + bytesAvailable=__value; \ + } \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_RECEIVE +* Purpose : receive data from socket +* Input : socketDescriptor - socket descriptor +* maxLength - max. size of bfufer +* Output : buffer - received data +* bytesReceive - length of received data +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_RECEIVE + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_RECEIVE(socketDescriptor,buffer,maxLength,bytesReceived) \ + do { \ + struct sockaddr_in __socketAddress; \ + socklen_t __socketAddressLength; \ + \ + memset(&__socketAddress,0,sizeof(__socketAddress)); \ + __socketAddressLength=sizeof(__socketAddress); \ + bytesReceived=recv(socketDescriptor,buffer,maxLength,0); \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_WITH_ADDRESS_PORT +* Purpose : receive data from socket +* Input : socketDescriptor - socket descriptor +* maxLength - max. size of bfufer +* Output : buffer - received data +* address - from address (NOT in network byte order!) +* port - from port (NOT in network byte order!) +* bytesReceive - length of received data +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_WITH_ADDRESS_PORT + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_WITH_ADDRESS_PORT(socketDescriptor,buffer,maxLength,address,port,bytesReceived) \ + do { \ + struct sockaddr_in __socketAddress; \ + socklen_t __socketAddressLength; \ + \ + port=0; \ + \ + memset(&__socketAddress,0,sizeof(__socketAddress)); \ + __socketAddressLength=sizeof(__socketAddress); \ + bytesReceived=recvfrom(socketDescriptor,buffer,maxLength,0,(struct sockaddr*)&__socketAddress,&__socketAddressLength); \ + if (__socketAddressLength==sizeof(__socketAddress)) \ + { \ + address=ntohl(__socketAddress.sin_addr.s_addr); \ + port =ntohs(__socketAddress.sin_port); \ + } \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_SEND +* Purpose : send data to socket +* Input : socketDescriptor - socket descriptor +* : buffer - data to send +* length - length of data to send +* Output : bytesSent - number of bytes sent, -1 otherwise +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_SEND + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_SEND(socketDescriptor,buffer,length,bytesSent) \ + do { \ + bytesSent=send(socketDescriptor,buffer,length,0); \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_SEND_WITH_ADDRESS_PORT +* Purpose : send data to socket +* Input : socketDescriptor - socket descriptor +* : buffer - data to send +* length - length of data to send +* Address - to address (NOT in network byte order!) +* Port - to port (NOT in network byte order!) +* Output : bytesSent - number of bytes sent, -1 otherwise +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_SEND_WITH_ADDRESS_PORT + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_SEND_WITH_ADDRESS_PORT(socketDescriptor,buffer,length,address,port,bytesSent) \ + do { \ + struct sockaddr_in __socketAddress; \ + \ + memset(&__socketAddress,0,sizeof(__socketAddress)); \ + __socketAddress.sin_family = AF_INET; \ + __socketAddress.sin_addr.s_addr = htonl(address); \ + __socketAddress.sin_port = htons((short)port); \ + bytesSent=sendto(socketDescriptor,buffer,length,0,(struct sockaddr*)&__socketAddress,sizeof(__socketAddress)); \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_TCP_NODELAY +* Purpose : set socket option TCP_NODELAY +* Input : socketDescriptor - socket descriptor +* flag - 1 or 0 +* Output : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_TCP_NODELAY + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/tcp.h> + #define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_TCP_NODELAY(socketDescriptor,flag,result) \ + do { \ + int __value; \ + \ + __value=flag; \ + result=(setsockopt(socketDescriptor,IPPROTO_TCP,TCP_NODELAY,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_LINGER +* Purpose : set socket option SO_LINGER +* Input : socketDescriptor - socket descriptor +* flag - 1 or 0 +* value - linger value +* Output : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_LINGER + #include <sys/types.h> + #include <sys/socket.h> + #define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_LINGER(socketDescriptor,flag,value,result) \ + do { \ + struct linger __linger; \ + \ + memset(&__linger,0,sizeof(__linger)); \ + if (flag) \ + { \ + __linger.l_onoff=0; \ + } \ + else \ + { \ + __linger.l_linger=value; \ + __linger.l_onoff =1; \ + } \ + result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_LINGER,&__linger,sizeof(__linger))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_TIMEOUT +* Purpose : set socket option SO_TIMEOUT +* Input : socketDescriptor - socket descriptor +* flag - 1 or 0 +* Output : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_TIMEOUT + #include <sys/types.h> + #include <sys/socket.h> + #define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_TIMEOUT(socketDescriptor,flag,result) \ + do { \ + struct timeval __value; \ + \ + __value.tv_sec = flag / 1000; \ + __value.tv_usec = (flag % 1000) * 1000; \ + result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_TIMEOUT,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_SNDBUF +* Purpose : set socket option SO_SNDBUF +* Input : socketDescriptor - socket descriptor +* size - size of send buffer +* Output : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_SNDBUF + #include <sys/types.h> + #include <sys/socket.h> + #define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_SNDBUF(socketDescriptor,size,result) \ + do { \ + int __value; \ + \ + __value=size; \ + result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_SNDBUF,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_RCDBUF +* Purpose : set socket option SO_RCDBUF +* Input : socketDescriptor - socket descriptor +* size - size of receive buffer +* Output : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_RCDBUF + #include <sys/types.h> + #include <sys/socket.h> + #define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_RCDBUF(socketDescriptor,size,result) \ + do { \ + int __value; \ + \ + __value=size; \ + result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_RCVBUF,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_IP_TTL +* Purpose : set socket option IP_TTL +* Input : socketDescriptor - socket descriptor +* value - value +* Output : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_IP_TTL + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_IP_TTL(socketDescriptor,value,result) \ + do { \ + int __value; \ + \ + __value=value; \ + result=(setsockopt(socketDescriptor,IPPROTO_IP,IP_TTL,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_IP_MULTICAST_IF +* Purpose : set socket option IP_MULTICAST_IF +* Input : socketDescriptor - socket descriptor +* address - integer with IP address in host-format +* Output : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_IP_MULTICAST_IF + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_IP_MULTICAST_IF(socketDescriptor,address,result) \ + do { \ + struct sockaddr_in __socketAddress; \ + \ + memset(&__socketAddress,0,sizeof(__socketAddress)); \ + __socketAddress.sin_family = AF_INET; \ + __socketAddress.sin_addr.s_addr = htonl(address); \ + result=(setsockopt(socketDescriptor,IPPROTO_IP,IP_MULTICAST_IF,&__socketAddress,sizeof(__socketAddress))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_REUSE_ADDRESS +* Purpose : set socket option REUSE_ADDRESS +* Input : socketDescriptor - socket descriptor +* flag - 1 or 0 +* Output : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_REUSE_ADDRESS + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_REUSE_ADDRESS(socketDescriptor,flag,result) \ + do { \ + int __value; \ + \ + __value=flag; \ + result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_REUSEADDR,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_ADD_MEMBERSHIP +* Purpose : set socket option IP_ADD_MEMBERSHIP +* Input : socketDescriptor - socket descriptor +* address - network address (host-format) +* Output : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_ADD_MEMBERSHIP + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_ADD_MEMBERSHIP(socketDescriptor,address,result) \ + do { \ + struct ip_mreq __request; \ + \ + memset(&__request,0,sizeof(__request)); \ + __request.imr_multiaddr.s_addr=htonl(address); \ + __request.imr_interface.s_addr=INADDR_ANY; \ + result=(setsockopt(socketDescriptor,IPPROTO_IP,IP_ADD_MEMBERSHIP,&__request,sizeof(__request))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_DROP_MEMBERSHIP +* Purpose : set socket option IP_DROP_MEMBERSHIP +* Input : socketDescriptor - socket descriptor +* address - network address (host-format) +* Output : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_DROP_MEMBERSHIP + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_DROP_MEMBERSHIP(socketDescriptor,address,result) \ + do { \ + struct ip_mreq __request; \ + \ + memset(&__request,0,sizeof(__request)); \ + __request.imr_multiaddr.s_addr=htonl(address); \ + __request.imr_interface.s_addr=INADDR_ANY; \ + result=(setsockopt(socketDescriptor,IPPROTO_IP,IP_DROP_MEMBERSHIP,&__request,sizeof(__request))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_KEEP_ALIVE +* Purpose : set socket option KEEP_ALIVE +* Input : socketDescriptor - socket descriptor +* flag - 1 or 0 +* Output : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_KEEP_ALIVE + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_KEEP_ALIVE(socketDescriptor,flag,result) \ + do { \ + int __value; \ + \ + __value=flag; \ + result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_KEEPALIVE,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_BROADCAST +* Purpose : set socket option SO_BROADCAST +* Input : socketDescriptor - socket descriptor +* flag - 1 or 0 +* Output : result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_BROADCAST + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/tcp.h> + #define TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_BROADCAST(socketDescriptor,flag,result) \ + do { \ + int __value; \ + \ + __value=flag; \ + result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_BROADCAST,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + } while (0) +#endif + +/*---------------------------------------------------------------------*/ + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_TCP_NODELAY +* Purpose : get socket option TCP_NODELAY +* Input : socketDescriptor - socket descriptor +* Output : flag - 1 or 0 +* result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_TCP_NODELAY + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/tcp.h> + #define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_TCP_NODELAY(socketDescriptor,flag,result) \ + do { \ + int __value; \ + socklen_t __len; \ + \ + flag=0; \ + \ + __len=sizeof(__value); \ + result=(getsockopt(socketDescriptor,IPPROTO_TCP,TCP_NODELAY,&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + if (result==TARGET_NATIVE_OK) \ + { \ + flag=__value; \ + } \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_LINGER +* Purpose : get socket option SO_LINGER +* Input : socketDescriptor - socket descriptor +* Output : flag - 1 or 0 +* value - linger value +* result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_LINGER + #include <sys/types.h> + #include <sys/socket.h> + #define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_LINGER(socketDescriptor,flag,value,result) \ + do { \ + struct linger __linger; \ + socklen_t __len; \ + \ + flag =0; \ + value=0; \ + \ + __len=sizeof(__linger); \ + result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_LINGER,&__linger,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + if (result==TARGET_NATIVE_OK) \ + { \ + flag =__linger.l_onoff; \ + value=__linger.l_linger; \ + } \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_TIMEOUT +* Purpose : get socket option SO_TIMEOUT +* Input : socketDescriptor - socket descriptor +* Output : flag - 1 or 0 +* result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_TIMEOUT + #include <sys/types.h> + #include <sys/socket.h> + #define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_TIMEOUT(socketDescriptor,flag,result) \ + do { \ + struct timeval __value; \ + socklen_t __len; \ + \ + flag=0; \ + \ + __len=sizeof(__value); \ + result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_TIMEOUT,&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + if (result==TARGET_NATIVE_OK) \ + { \ + flag = (__value.tv_sec * 1000LL) + (__value.tv_usec / 1000LL); \ + } \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_SNDBUF +* Purpose : get socket option SO_SNDBUF +* Input : socketDescriptor - socket descriptor +* Output : size - size of send buffer +* result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_SNDBUF + #include <sys/types.h> + #include <sys/socket.h> + #define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_SNDBUF(socketDescriptor,size,result) \ + do { \ + int __value; \ + socklen_t __len; \ + \ + size=0; \ + \ + __len=sizeof(__value); \ + result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_SNDBUF,&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + if (result==TARGET_NATIVE_OK) \ + { \ + size=__value; \ + } \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_RCDBUF +* Purpose : get socket option SO_RCDBUF +* Input : socketDescriptor - socket descriptor +* Output : size - size of receive buffer +* result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_RCDBUF + #include <sys/types.h> + #include <sys/socket.h> + #define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_RCDBUF(socketDescriptor,size,result) \ + do { \ + int __value; \ + socklen_t __len; \ + \ + size=0; \ + \ + __len=sizeof(__value); \ + result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_RCVBUF,&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + if (result==TARGET_NATIVE_OK) \ + { \ + size=__value; \ + } \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_IP_TTL +* Purpose : get socket option IP_TTL +* Input : socketDescriptor - socket descriptor +* Output : flag - 1 or 0 +* result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_IP_TTL + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_IP_TTL(socketDescriptor,flag,result) \ + do { \ + int __value; \ + socklen_t __len; \ + \ + flag=0; \ + \ + __len=sizeof(__value); \ + result=(getsockopt(socketDescriptor,IPPROTO_IP,IP_TTL,&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + if (result==TARGET_NATIVE_OK) \ + { \ + flag=__value; \ + } \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_IP_MULTICAST_IF +* Purpose : get socket option IP_MULTICAST_IF +* Input : socketDescriptor - socket descriptor +* Output : address - integer with IP address in host-format +* result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_IP_MULTICAST_IF + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_IP_MULTICAST_IF(socketDescriptor,address,result) \ + do { \ + struct sockaddr_in __socketAddress; \ + socklen_t __socketAddressLength; \ + \ + address=0;\ + \ + memset(&__socketAddress,0,sizeof(__socketAddress)); \ + __socketAddress.sin_family = AF_INET; \ + __socketAddress.sin_addr.s_addr = htonl(address); \ + __socketAddressLength=sizeof(__socketAddress); \ + result=(getsockopt(socketDescriptor,IPPROTO_IP,IP_MULTICAST_IF,&__socketAddress,&__socketAddressLength)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + if (result==TARGET_NATIVE_OK) \ + { \ + address=ntohl(__socketAddress.sin_addr.s_addr); \ + } \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_BIND_ADDRESS +* Purpose : get socket option SOCKOPT_SO_BINDADDR +* Input : socketDescriptor - socket descriptor +* Output : address - integer with IP address in host-format +* result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_BIND_ADDRESS + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_BIND_ADDRESS(socketDescriptor,address,result) \ + do { \ + struct sockaddr_in __socketAddress; \ + socklen_t __socketAddressLength; \ + \ + address=0;\ + \ + memset(&__socketAddress,0,sizeof(__socketAddress)); \ + __socketAddressLength=sizeof(__socketAddress); \ + result=(getsockname(socketDescriptor,(struct sockaddr*)&__socketAddress,&__socketAddressLength)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + if (result==TARGET_NATIVE_OK) \ + { \ + address=ntohl(__socketAddress.sin_addr.s_addr); \ + } \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_REUSE_ADDRESS +* Purpose : get socket option REUSE_ADDRESS +* Input : socketDescriptor - socket descriptor +* Output : flag - 1 or 0 +* result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_REUSE_ADDRESS + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_REUSE_ADDRESS(socketDescriptor,flag,result) \ + do { \ + int __value; \ + socklen_t __len; \ + \ + flag=0; \ + \ + __len=sizeof(__value); \ + result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_REUSEADDR,&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + if (result==TARGET_NATIVE_OK) \ + { \ + flag=__value; \ + } \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_KEEP_ALIVE +* Purpose : get socket option KEEP_ALIVE +* Input : socketDescriptor - socket descriptor +* Output : flag - 1 or 0 +* result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_KEEP_ALIVE + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_KEEP_ALIVE(socketDescriptor,flag,result) \ + do { \ + int __value; \ + socklen_t __len; \ + \ + flag=0; \ + \ + __len=sizeof(__value); \ + result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_KEEPALIVE,&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + if (result==TARGET_NATIVE_OK) \ + { \ + flag=__value; \ + } \ + } while (0) +#endif + +/***********************************************************************\ +* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_BROADCAST +* Purpose : get socket option SO_BROADCAST +* Input : socketDescriptor - socket descriptor +* Output : flag - 1 or 0 +* result - TARGET_NATIVE_OK if no error occurred, +* TARGET_NATIVE_ERROR otherwise +* Return : - +* Side-effect: unknown +* Notes : - +\***********************************************************************/ + +#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_BROADCAST + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/tcp.h> + #define TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_BROADCAST(socketDescriptor,flag,result) \ + do { \ + int __value; \ + socklen_t __len; \ + \ + flag=0; \ + \ + __len=sizeof(__value); \ + result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_BROADCAST,&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \ + if (result==TARGET_NATIVE_OK) \ + { \ + flag=__value; \ + } \ + } while (0) +#endif + +/***************************** Functions *******************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __TARGET_GENERIC_NETWORK__ */ + +/* end of file */ + diff --git a/libjava/classpath/native/target/readme.txt b/libjava/classpath/native/target/readme.txt new file mode 100644 index 0000000..6fee79e --- /dev/null +++ b/libjava/classpath/native/target/readme.txt @@ -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 + + |