[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] Patching of native/target
From: |
Torsten Rupp |
Subject: |
[cp-patches] Patching of native/target |
Date: |
Tue, 09 Nov 2004 10:36:23 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 |
Dear Classpath-members,
currently I'm looking for some suitable way to contribute the changes of
aicas in the native layer and introduce the new POSIX layer to
Classpath. For a simple migration, I think it would be useful first to
make the changes in the existing layers and then add the new POSIX layer
(my fist attempt in my last patch of jcl.c - malloc() and free() - for
doing this step by step fail). I would also like to keep the old layers
for some time until everything is upgraded and tested (e. g. the new
layer use macros with a name CP_... as discussed in the mailing list;
this have to be changed in all C sources).
If possible I would like to send patch files like below which contain
multiple patches. To separate the changes into single simpler patches is
a lot of work and there is a risk for adding new errors when doing this.
I hope such patches will also be accepted (documentation in the
ChangeLog preconditioned).
Sincerely,
Torsten
PS: if you want to try the patch: the patch already include the
temporary "switch" (#ifdef NEW_CP) for the new POSIX layer, but please
still do not use it! (do not defined "NEW_CP")
diff -ruN --exclude='.*' --exclude='Entries*' --exclude=Repository
--exclude=Root --exclude 'target_generic_math_*'
classpath.org/native/target/generic/target_generic.c
classpath/native/target/generic/target_generic.c
--- classpath.org/native/target/generic/target_generic.c Thu Jan 1
01:00:00 1970
+++ classpath/native/target/generic/target_generic.c Thu Sep 30 11:40:42 2004
@@ -0,0 +1,75 @@
+/* target_generic.c - Native methods generic 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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
+*/
+
+/****************************** 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 *******************************/
+
+int targetNativeLastErrorCode=0;
+char targetNativeLastErrorString[TARGET_NATIVE_MAX_ERROR_STRING_LENGTH];
+
+/****************************** Macros *********************************/
+
+/***************************** Functions *******************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/* end of file */
+
diff -ruN --exclude='.*' --exclude='Entries*' --exclude=Repository
--exclude=Root --exclude 'target_generic_math_*'
classpath.org/native/target/generic/target_generic.h
classpath/native/target/generic/target_generic.h
--- classpath.org/native/target/generic/target_generic.h Mon Mar 29
09:07:40 2004
+++ classpath/native/target/generic/target_generic.h Tue Oct 19 11:31:36 2004
@@ -1,4 +1,4 @@
-/* generic_math_int64.h - Native methods for 64bit math operations
+/* target_generic.h - Native methods for generic operations
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -54,13 +54,21 @@
#include <stdlib.h>
#include <errno.h>
+#include <string.h>
+
+#ifdef NEW_CP
+#include "../posix/target_posix.h"
+#endif
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
+#ifndef NEW_CP
#define TARGET_NATIVE_OK 1
#define TARGET_NATIVE_ERROR 0
+#define TARGET_NATIVE_MAX_ERROR_STRING_LENGTH 128
+
#ifndef TARGET_NATIVE_ERROR_PERMISION_DENIED
#define TARGET_NATIVE_ERROR_PERMISION_DENIED EACCES
#endif
@@ -103,11 +111,66 @@
#ifndef TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL
#define TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL EINTR
#endif
+#else /* NEW_CP */
+#define TARGET_NATIVE_OK CP_OK
+#define TARGET_NATIVE_ERROR CP_ERROR
+
+#define TARGET_NATIVE_MAX_ERROR_STRING_LENGTH CP_MAX_ERROR_STRING_LENGTH
+
+#ifndef TARGET_NATIVE_ERROR_PERMISION_DENIED
+ #define TARGET_NATIVE_ERROR_PERMISION_DENIED CP_ERROR_PERMISION_DENIED
+#endif
+#ifndef TARGET_NATIVE_ERROR_BAD_FILE_DESCRIPTOR
+ #define TARGET_NATIVE_ERROR_BAD_FILE_DESCRIPTOR
CP_ERROR_BAD_FILE_DESCRIPTOR
+#endif
+#ifndef TARGET_NATIVE_ERROR_FILE_EXISTS
+ #define TARGET_NATIVE_ERROR_FILE_EXISTS CP_ERROR_FILE_EXISTS
+#endif
+#ifndef TARGET_NATIVE_ERROR_INPUT_OUTPUT
+ #define TARGET_NATIVE_ERROR_INPUT_OUTPUT CP_ERROR_INPUT_OUTPUT
+#endif
+#ifndef TARGET_NATIVE_ERROR_TOO_MANY_OPEN_FILES
+ #define TARGET_NATIVE_ERROR_TOO_MANY_OPEN_FILES
CP_ERROR_TOO_MANY_OPEN_FILES
+#endif
+#ifndef TARGET_NATIVE_ERROR_FILENAME_TO_LONG
+ #define TARGET_NATIVE_ERROR_FILENAME_TO_LONG CP_ERROR_INPUT_OUTPUT
+#endif
+#ifndef TARGET_NATIVE_ERROR_NO_SUCH_DEVICE
+ #define TARGET_NATIVE_ERROR_NO_SUCH_DEVICE CP_ERROR_NO_SUCH_DEVICE
+#endif
+#ifndef TARGET_NATIVE_ERROR_NO_SUCH_FILE
+ #define TARGET_NATIVE_ERROR_NO_SUCH_FILE CP_ERROR_NO_SUCH_FILE
+#endif
+#ifndef TARGET_NATIVE_ERROR_NO_SPACE_LEFT
+ #define TARGET_NATIVE_ERROR_NO_SPACE_LEFT CP_ERROR_NO_SPACE_LEFT
+#endif
+#ifndef TARGET_NATIVE_ERROR_DIRECTORY_NOT_EMPTY
+ #define TARGET_NATIVE_ERROR_DIRECTORY_NOT_EMPTY
CP_ERROR_DIRECTORY_NOT_EMPTY
+#endif
+#ifndef TARGET_NATIVE_ERROR_OPERATION_NOT_PERMITTED
+ #define TARGET_NATIVE_ERROR_OPERATION_NOT_PERMITTED
CP_ERROR_OPERATION_NOT_PERMITTED
+#endif
+#ifndef TARGET_NATIVE_ERROR_READ_ONLY_FILE_SYSTEM
+ #define TARGET_NATIVE_ERROR_READ_ONLY_FILE_SYSTEM
CP_ERROR_READ_ONLY_FILE_SYSTEM
+#endif
+#ifndef TARGET_NATIVE_ERROR_INVALID_SEEK
+ #define TARGET_NATIVE_ERROR_INVALID_SEEK CP_ERROR_INVALID_SEEK
+#endif
+#ifndef TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL
+ #define TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL
CP_ERROR_INTERRUPT_FUNCTION_CALL
+#endif
+#endif /* NEW_CP */
/***************************** Datatypes *******************************/
/***************************** Variables *******************************/
+#ifndef NEW_CP
+extern int targetNativeLastErrorCode;
+extern char targetNativeLastErrorString[];
+#else /* NEW_CP */
+#endif /* NEW_CP */
+
/****************************** Macros *********************************/
/***********************************************************************\
@@ -117,14 +180,20 @@
* Output : -
* Return : error code
* Side-effect: unknown
-* Notes : -
+* Notes : return errno if not 0, otherwise return last set error
+* code
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_LAST_ERROR
#include <errno.h>
#define TARGET_NATIVE_LAST_ERROR() \
- errno
+
((errno!=0)?errno:((targetNativeLastErrorCode!=0)?targetNativeLastErrorCode:0))
#endif
+#else /* NEW_CP */
+ #define TARGET_NATIVE_LAST_ERROR() \
+ CP_LAST_ERROR()
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_LAST_ERROR_STRING
@@ -133,27 +202,76 @@
* Output : -
* Return : error string (read only!)
* Side-effect: unknown
-* Notes : -
+* Notes : return system error string if errno is not 0, otherwise
+* return last set error string
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_LAST_ERROR_STRING
#include <string.h>
#include <errno.h>
#define TARGET_NATIVE_LAST_ERROR_STRING() \
- strerror(errno)
+
((errno!=0)?strerror(errno):((targetNativeLastErrorCode!=0)?targetNativeLastErrorString:""))
#endif
+#else /* NEW_CP */
+ #define TARGET_NATIVE_LAST_ERROR_STRING() \
+ CP_LAST_ERROR_STRING()
+#endif /* NEW_CP */
+#ifndef NEW_CP
+/* NYI ??? buffer size? */
#ifndef TARGET_NATIVE_LAST_ERROR_STRING_FORMAT
#include <string.h>
#include <errno.h>
#define TARGET_NATIVE_LAST_ERROR_STRING_FORMAT(buffer,bufferSize,format) \
- do { \
+ do \
+ { \
sprintf(buffer,format); \
strcat(" (error: "); \
- strcat(strerror(errno)); \
+ if (errno!=0) \
+ { \
+ strcat(strerror(errno)); \
+ } \
+ else if (targetNativeLastErrorCode!=0) \
+ { \
+ strcat(targetNativeLastErrorString); \
+ } \
+ else \
+ { \
+ strcat("none"); \
+ } \
strcat(")"); \
} while (0)
#endif
+#else /* NEW_CP */
+ #define TARGET_NATIVE_LAST_ERROR_STRING_FORMAT(buffer,bufferSize,format) \
+ CP_LAST_ERROR_STRING_FORMAT(buffer,bufferSize,format
+#endif /* NEW_CP */
+
+/***********************************************************************\
+* Name : TARGET_NATIVE_SET_LAST_ERROR
+* Purpose : set last error code and string
+* Input : errorCode - error code
+* errorString - error string
+* Output : -
+* Return : -
+* Side-effect: unknown
+* Notes : -
+\***********************************************************************/
+
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_SET_LAST_ERROR
+ #define TARGET_NATIVE_SET_LAST_ERROR(errorCode,errorString) \
+ do { \
+ errno=0; \
+ targetNativeLastErrorCode=errorCode; \
+
strncpy(targetNativeLastErrorString,errorString,TARGET_NATIVE_MAX_ERROR_STRING_LENGTH);
\
+ } while(0)
+#endif
+#else /* NEW_CP */
+ #define TARGET_NATIVE_SET_LAST_ERROR(errorCode,errorString) \
+ CP_SET_LAST_ERROR(errorCode,errorString)
+#endif /* NEW_CP */
/***************************** Functions *******************************/
@@ -169,3 +287,4 @@
/* end of file */
+
diff -ruN --exclude='.*' --exclude='Entries*' --exclude=Repository
--exclude=Root --exclude 'target_generic_math_*'
classpath.org/native/target/generic/target_generic_file.h
classpath/native/target/generic/target_generic_file.h
--- classpath.org/native/target/generic/target_generic_file.h Sat Apr 24
00:06:24 2004
+++ classpath/native/target/generic/target_generic_file.h Thu Oct 7
17:39:43 2004
@@ -1,5 +1,5 @@
-/* target_generic_file - Native methods for file operations
- Copyright (C) 1998, 2004 Free Software Foundation, Inc.
+/* target_generic_file.h - Native methods for generic file operations
+ Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,10 +43,6 @@
#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!
@@ -58,14 +54,33 @@
#include <stdlib.h>
#include <assert.h>
-#include <fcntl.h>
#include "target_native.h"
-#include "target_native_math_int.h"
+#include "target_native_math.h"
+
+/* needed for O_* flags */
+#ifdef HAVE_FCNTL_H
+ #include <fcntl.h>
+#endif
+
+#ifdef NEW_CP
+#include "../posix/target_posix_file.h"
+#endif
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_FILE_STDIN
+ #define TARGET_NATIVE_FILE_STDIN 0
+#endif
+#ifndef TARGET_NATIVE_FILE_STDOUT
+ #define TARGET_NATIVE_FILE_STDOUT 1
+#endif
+#ifndef TARGET_NATIVE_FILE_STDERR
+ #define TARGET_NATIVE_FILE_STDERR 2
+#endif
+
#ifndef TARGET_NATIVE_FILE_FILEFLAG_NONE
#define TARGET_NATIVE_FILE_FILEFLAG_NONE 0
#endif
@@ -99,13 +114,17 @@
#endif
#ifndef TARGET_NATIVE_FILE_FILEFLAG_DSYNC
#ifdef O_DSYNC
- #define TARGET_NATIVE_FILE_FILEFLAG_DSYNC 0
+ #define TARGET_NATIVE_FILE_FILEFLAG_DSYNC O_DSYNC
#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
+ #ifdef O_BINARY
+ #define TARGET_NATIVE_FILE_FILEFLAG_BINARY O_BINARY
+ #else
+ #define TARGET_NATIVE_FILE_FILEFLAG_BINARY 0
+ #endif
#endif
#ifndef TARGET_NATIVE_FILE_FILEPERMISSION_NORMAL
@@ -120,6 +139,66 @@
#define TARGET_NATIVE_FILE_FILEPERMISSION_READONLY
(~(S_IWRITE|S_IWGRP|S_IWOTH))
#endif
+#else /* NEW_CP */
+
+#ifndef TARGET_NATIVE_FILE_STDIN
+ #define TARGET_NATIVE_FILE_STDIN CP_FILE_STDIN
+#endif
+#ifndef TARGET_NATIVE_FILE_STDOUT
+ #define TARGET_NATIVE_FILE_STDOUT CP_FILE_STDOUT
+#endif
+#ifndef TARGET_NATIVE_FILE_STDERR
+ #define TARGET_NATIVE_FILE_STDERR CP_FILE_STDERR
+#endif
+
+#ifndef TARGET_NATIVE_FILE_FILEFLAG_NONE
+ #define TARGET_NATIVE_FILE_FILEFLAG_NONE CP_FILE_FILEFLAG_NONE
+#endif
+#ifndef TARGET_NATIVE_FILE_FILEFLAG_CREATE
+ #define TARGET_NATIVE_FILE_FILEFLAG_CREATE CP_FILE_FILEFLAG_CREATE
+#endif
+#ifndef TARGET_NATIVE_FILE_FILEFLAG_CREATE_FORCE
+ #define TARGET_NATIVE_FILE_FILEFLAG_CREATE_FORCE
CP_FILE_FILEFLAG_CREATE_FORCE
+#endif
+#ifndef TARGET_NATIVE_FILE_FILEFLAG_READ
+ #define TARGET_NATIVE_FILE_FILEFLAG_READ CP_FILE_FILEFLAG_READ
+#endif
+#ifndef TARGET_NATIVE_FILE_FILEFLAG_WRITE
+ #define TARGET_NATIVE_FILE_FILEFLAG_WRITE CP_FILE_FILEFLAG_WRITE
+#endif
+#ifndef TARGET_NATIVE_FILE_FILEFLAG_READWRITE
+ #define TARGET_NATIVE_FILE_FILEFLAG_READWRITE CP_FILE_FILEFLAG_READWRITE
+#endif
+#ifndef TARGET_NATIVE_FILE_FILEFLAG_TRUNCATE
+ #define TARGET_NATIVE_FILE_FILEFLAG_TRUNCATE CP_FILE_FILEFLAG_TRUNCATE
+#endif
+#ifndef TARGET_NATIVE_FILE_FILEFLAG_APPEND
+ #define TARGET_NATIVE_FILE_FILEFLAG_APPEND CP_FILE_FILEFLAG_APPEND
+#endif
+#ifndef TARGET_NATIVE_FILE_FILEFLAG_SYNC
+ #define TARGET_NATIVE_FILE_FILEFLAG_SYNC CP_FILE_FILEFLAG_SYNC
+#endif
+#ifndef TARGET_NATIVE_FILE_FILEFLAG_DSYNC
+ #define TARGET_NATIVE_FILE_FILEFLAG_DSYNC CP_FILE_FILEFLAG_DSYNC
+#endif
+#ifndef TARGET_NATIVE_FILE_FILEFLAG_BINARY
+ #define TARGET_NATIVE_FILE_FILEFLAG_BINARY CP_FILE_FILEFLAG_BINARY
+#endif
+
+#ifndef TARGET_NATIVE_FILE_FILEPERMISSION_NORMAL
+ #define TARGET_NATIVE_FILE_FILEPERMISSION_NORMAL
CP_FILE_FILEPERMISSION_NORMAL
+#endif
+
+#ifndef TARGET_NATIVE_FILE_FILEPERMISSION_PRIVATE
+ #define TARGET_NATIVE_FILE_FILEPERMISSION_PRIVATE
CP_FILE_FILEPERMISSION_PRIVATE
+#endif
+
+#ifndef TARGET_NATIVE_FILE_FILEPERMISSION_READONLY
+ #define TARGET_NATIVE_FILE_FILEPERMISSION_READONLY
CP_FILE_FILEPERMISSION_READONLY
+#endif
+
+#endif /* NEW_CP */
+
/***************************** Datatypes *******************************/
/***************************** Variables *******************************/
@@ -129,164 +208,237 @@
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_OPEN
* Purpose : open a file
-* Input : -
-* Output : -
+* Input : filename - filename
+* flags - file open flags
+* permissions - file permissions
+* Output : filedescriptor - file descriptor
+* result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : file is created if it does not exist
\***********************************************************************/
-
+#include <stdio.h>
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_FILE_OPEN
#include <sys/types.h>
#include <sys/stat.h>
- #include <fcntl.h>
+ #ifdef HAVE_FCNTL_H
+ #include <fcntl.h>
+ #endif
+ #ifdef FD_CLOEXEC_IN_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)
+ #else
+ #define
TARGET_NATIVE_FILE_OPEN(filename,filedescriptor,flags,permissions,result) \
+ do { \
+ filedescriptor=open(filename, \
+ flags, \
+ permissions \
+ ); \
+ result=(filedescriptor>=0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+ } while (0)
+ #endif
+#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_OPEN
#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)
+ CP_FILE_OPEN(filename,filedescriptor,flags,permissions,result)
#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_OPEN_CREATE
-* Purpose : create a file
-* Input : -
-* Output : -
+* Purpose : create a file and open for writing
+* Input : filename - filename
+* Output : filedescriptor - file descriptor
+* result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : file is created if it does not exist
\***********************************************************************/
+#ifndef NEW_CP
#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_FILEFLAG_WRITE|TARGET_NATIVE_FILE_FILEFLAG_CREATE_FORCE|TARGET_NATIVE_FILE_FILEFLAG_BINARY,
\
TARGET_NATIVE_FILE_FILEPERMISSION_NORMAL, \
result \
)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_OPEN_CREATE
+ #define TARGET_NATIVE_FILE_OPEN_CREATE(filename,filedescriptor,result) \
+ CP_FILE_OPEN_CREATE(filename,filedescriptor,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_OPEN_READ
* Purpose : open an existing file for reading
-* Input : -
-* Output : -
+* Input : filename - filename
+* Output : filedescriptor - file descriptor
+* result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#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_FILEFLAG_READ|TARGET_NATIVE_FILE_FILEFLAG_BINARY, \
TARGET_NATIVE_FILE_FILEPERMISSION_NORMAL, \
result \
)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_OPEN_READ
+ #define TARGET_NATIVE_FILE_OPEN_READ(filename,filedescriptor,result) \
+ CP_FILE_OPEN_READ(filename,filedescriptor,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_OPEN_WRITE
* Purpose : open an existing file for writing
-* Input : -
-* Output : -
+* Input : filename - filename
+* Output : filedescriptor - file descriptor
+* result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#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_FILEFLAG_WRITE|TARGET_NATIVE_FILE_FILEFLAG_BINARY, \
TARGET_NATIVE_FILE_FILEPERMISSION_NORMAL, \
result \
)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_OPEN_WRITE
+ #define TARGET_NATIVE_FILE_OPEN_WRITE(filename,filedescriptor,result) \
+ CP_FILE_OPEN_WRITE(filename,filedescriptor,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_OPEN_READWRITE
* Purpose : create/open a file for reading/writing
-* Input : -
-* Output : -
+* Input : filename - filename
+* Output : filedescriptor - file descriptor
+* result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : file is created if it does not exist
\***********************************************************************/
+#ifndef NEW_CP
#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_FILEFLAG_READWRITE|TARGET_NATIVE_FILE_FILEFLAG_BINARY, \
TARGET_NATIVE_FILE_FILEPERMISSION_NORMAL, \
result \
)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_OPEN_READWRITE
+ #define TARGET_NATIVE_FILE_OPEN_READWRITE(filename,filedescriptor,result) \
+ CP_FILE_OPEN_READWRITE(filename,filedescriptor,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_OPEN_READWRITE
* Purpose : create/open a file for append
-* Input : -
-* Output : -
+* Input : filename - filename
+* Output : filedescriptor - file descriptor
+* result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : file is created if it does not exist
\***********************************************************************/
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_FILE_OPEN_APPEND
+ #define TARGET_NATIVE_FILE_OPEN_APPEND(filename,filedescriptor,result) \
+ TARGET_NATIVE_FILE_OPEN(filename, \
+ filedescriptor, \
+
TARGET_NATIVE_FILE_FILEFLAG_CREATE|TARGET_NATIVE_FILE_FILEFLAG_WRITE|TARGET_NATIVE_FILE_FILEFLAG_APPEND|TARGET_NATIVE_FILE_FILEFLAG_BINARY,
\
+ TARGET_NATIVE_FILE_FILEPERMISSION_NORMAL, \
+ result \
+ )
+#endif
+#else /* NEW_CP */
#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 \
- )
+ CP_FILE_OPEN_APPEND(filename,filedescriptor,result)
#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_CLOSE
* Purpose : close a file
-* Input : -
-* Output : -
+* Input : filedescriptor - file descriptor
+* Output : result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#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; \
+ result =
(close(filedescriptor)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_CLOSE
+ #define TARGET_NATIVE_FILE_CLOSE(filedescriptor,result) \
+ CP_FILE_CLOSE(filedescriptor,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_VALID_FILE_DESCRIPTOR
* Purpose : check if file-descriptor is valid
-* Input : -
-* Output : -
+* Input : filedescriptor - file descriptor
+* Output : result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#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;
\
+ result =
(fcntl(filedescriptor,F_GETFL,0)!=-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while(0)
#elif defined(HAVE_FSTAT)
#include <sys/types.h>
@@ -296,50 +448,67 @@
do { \
struct stat __stat; \
\
-
result=(fstat(filedescriptor,&__stat)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
+ 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
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_VALID_FILE_DESCRIPTOR
+ #define TARGET_NATIVE_FILE_VALID_FILE_DESCRIPTOR(filedescriptor,result) \
+ CP_FILE_VALID_FILE_DESCRIPTOR(filedescriptor,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_TELL
* Purpose : get current file position
-* Input : -
-* Output : -
+* Input : filedescriptor - file descriptor
+* Output : tell - position
+* result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#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; \
+ offset = lseek(filedescriptor,0,SEEK_CUR); \
+ result = ((offset)!=(off_t)-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_TELL
+ #define TARGET_NATIVE_FILE_TELL(filedescriptor,offset,result) \
+ CP_FILE_TELL(filedescriptor,offset,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_SEEK_BEGIN|CURRENT|END
* Purpose : set file position relativ to begin/current/end
-* Input : -
-* Output : -
+* Input : filedescriptor - file descriptor
+* offset - file position
+* Output : newoffset - new file position
+* result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#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; \
+ 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
@@ -347,8 +516,8 @@
#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; \
+ 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
@@ -356,39 +525,62 @@
#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; \
+ newoffset = lseek(filedescriptor,offset,SEEK_END); \
+ result = ((newoffset)!=(off_t)-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_SEEK_BEGIN
+ #define
TARGET_NATIVE_FILE_SEEK_BEGIN(filedescriptor,offset,newoffset,result) \
+ CP_FILE_SEEK_BEGIN(filedescriptor,offset,newoffset,result)
+#endif
+#ifndef TARGET_NATIVE_FILE_SEEK_CURRENT
+ #define
TARGET_NATIVE_FILE_SEEK_CURRENT(filedescriptor,offset,newoffset,result) \
+ CP_FILE_SEEK_CURRENT(filedescriptor,offset,newoffset,result)
+#endif
+#ifndef TARGET_NATIVE_FILE_SEEK_END
+ #define TARGET_NATIVE_FILE_SEEK_END(filedescriptor,offset,newoffset,result) \
+ CP_FILE_SEEK_END(filedescriptor,offset,newoffset,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_TRUNCATE
* Purpose : truncate a file
-* Input : -
+* Input : filedescriptor - file descriptor
* Output : -
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#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;
\
+ result =
(ftruncate(filedescriptor,offset)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_TRUNCATE
+ #define TARGET_NATIVE_FILE_TRUNCATE(filedescriptor,offset,result) \
+ CP_FILE_TRUNCATE(filedescriptor,offset,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_SIZE
* Purpose : get size of file (in bytes)
-* Input : -
-* Output : -
+* Input : filedescriptor - file descriptor
+* Output : length - file size
+* result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_FILE_SIZE
#include <sys/types.h>
#include <sys/stat.h>
@@ -397,36 +589,107 @@
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); \
+ 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
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_SIZE
+ #define TARGET_NATIVE_FILE_SIZE(filedescriptor,length,result) \
+ CP_FILE_SIZE(filedescriptor,length,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_AVAILABLE
* Purpose : get available bytes for read
-* Input : -
-* Output : -
-* Return : -
-* Side-effect: unknown
-* Notes : -
+* Input : filedescriptor - file descriptor
+* Output : length - available bytes
+* result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
+* Return : -
+* Side-effect: unknown
+* Notes : Hint: 4 different methods are available
+* - ioctl FIONREAD
+* - fstat()+select() (get number of available bytes for
+* files and 0/1 for block/character devices)
+* - fstat() (get number of available bytes for files, 0
+* otherwise)
+* - select() (return 0/1 only)
+* Depending on the configuration the best available method
+* is selected (do not rearrange the if-elif-blocks!)
\***********************************************************************/
+#ifndef NEW_CP
#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)
+ #if defined(HAVE_FIONREAD) || defined(FIONREAD_IN_SYS_IOCTL_H) ||
defined(FIONREAD_IN_SYS_FILIO_H)
+ #ifdef HAVE_FIONREAD
+ #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
+ #else
+ #if defined(FIONREAD_IN_SYS_IOCTL_H)
+ #include <sys/ioctl.h>
+ #elif defined(FIONREAD_IN_SYS_FILIO_H)
+ #include <sys/types.h>
+ #include <sys/filio.h>
+ #endif
+ #endif
#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); \
+ 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) && defined(HAVE_SELECT)
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <unistd.h>
+ #include <string.h>
+ #include <sys/select.h>
+ #define TARGET_NATIVE_FILE_AVAILABLE(filedescriptor,length,result) \
+ do { \
+ struct stat __statBuffer; \
+ off_t __n; \
+ fd_set __filedescriptset; \
+ struct timeval __timeval; \
+ \
+ length=TARGET_NATIVE_MATH_INT_INT64_CONST_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 \
+ { \
+ FD_ZERO(&__filedescriptset); \
+ FD_SET(filedescriptor,&__filedescriptset); \
+ memset(&__timeval,0,sizeof(__timeval)); \
+ /* Hint: __filedescriptset is a set of bits, thus the size of the
used set
+ elements is the last element+1, e. g. filescriptor is 3,
then
+ __filedescriptset is 0001000... thus...
+ |--| size is 4 (not 3!)
+ */ \
+ switch
(select(filedescriptor+1,&__filedescriptset,NULL,NULL,&__timeval)==0) \
+ { \
+ case -1:
result=TARGET_NATIVE_ERROR; break; \
+ case 0: length=TARGET_NATIVE_MATH_INT_INT64_CONST_0;
result=TARGET_NATIVE_OK; break; \
+ default: length=TARGET_NATIVE_MATH_INT_INT64_CONST_1;
result=TARGET_NATIVE_OK; break; \
+ } \
+ } \
} while (0)
#elif defined(HAVE_FSTAT)
#include <sys/types.h>
@@ -437,24 +700,24 @@
struct stat __statBuffer; \
off_t __n; \
\
- length=0; \
+ length=TARGET_NATIVE_MATH_INT_INT64_CONST_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; \
+ length =
TARGET_NATIVE_MATH_INT_INT32_TO_INT64(__statBuffer.st_size-__n); \
+ result = TARGET_NATIVE_OK; \
} \
else \
{ \
- result=TARGET_NATIVE_ERROR; \
+ result = TARGET_NATIVE_ERROR; \
} \
} \
else \
{ \
- result=TARGET_NATIVE_ERROR; \
+ result = TARGET_NATIVE_ERROR; \
} \
} while (0)
#elif defined(HAVE_SELECT)
@@ -465,44 +728,63 @@
fd_set __filedescriptset; \
struct timeval __timeval; \
\
- length=0; \
+ length=TARGET_NATIVE_MATH_INT_INT64_CONST_0; \
\
FD_ZERO(&__filedescriptset); \
FD_SET(filedescriptor,&__filedescriptset); \
memset(&__timeval,0,sizeof(__timeval)); \
+ /* Hint: __filedescriptset is a set of bits, thus the size of the used
set
+ elements is the last element+1, e. g. filescriptor is 3, then
+ __filedescriptset is 0001000... thus...
+ |--| size is 4 (not 3!)
+ */ \
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; \
+ case -1:
result=TARGET_NATIVE_ERROR; break; \
+ case 0: length=TARGET_NATIVE_MATH_INT_INT64_CONST_0;
result=TARGET_NATIVE_OK; break; \
+ default: length=TARGET_NATIVE_MATH_INT_INT64_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)
+ #ifndef WITHOUT_FILESYSTEM
+ #error No suitable implementation for TARGET_NATIVE_FILE_AVAILABLE -
please check configuration!
+ #else
+ #define TARGET_NATIVE_FILE_AVAILABLE(filedescriptor,length,result) \
+ do { \
+ errno = TARGET_NATIVE_ERROR_OPERATION_NOT_PERMITTED; \
+ length = TARGET_NATIVE_MATH_INT_INT64_CONST_0; \
+ result = TARGET_NATIVE_ERROR; \
+ } while (0)
+ #endif
#endif
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_AVAILABLE
+ #define TARGET_NATIVE_FILE_AVAILABLE(filedescriptor,length,result) \
+ CP_FILE_AVAILABLE(filedescriptor,length,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_READ|WRITE
-* Purpose : read/write from/to frile
-* Input : -
-* Output : -
+* Purpose : read/write from/to file
+* Input : filedescriptor - file descriptor
+* length - number of bytes to read
+* Output : buffer - buffer with read bytes
+* bytesRead - number of bytes read
+* result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#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; \
+ result = (bytesRead!=-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
#ifndef TARGET_NATIVE_FILE_WRITE
@@ -510,20 +792,31 @@
#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; \
+ result = (bytesWritten!=-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_READ
+ #define
TARGET_NATIVE_FILE_READ(filedescriptor,buffer,length,bytesRead,result) \
+ CP_FILE_READ(filedescriptor,buffer,length,bytesRead,result)
+#endif
+#ifndef TARGET_NATIVE_FILE_WRITE
+ #define
TARGET_NATIVE_FILE_WRITE(filedescriptor,buffer,length,bytesWritten,result) \
+ CP_FILE_WRITE(filedescriptor,buffer,length,bytesWritten,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_SET_MODE_READONLY
* Purpose : set file mode to read-only
-* Input : -
-* Output : -
+* Input : filename - filename
+* Output : result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_FILE_SET_MODE_READONLY
#include <sys/types.h>
#include <sys/stat.h>
@@ -533,23 +826,30 @@
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;
\
+ result = (chmod(filename,__statBuffer.st_mode &
TARGET_NATIVE_FILE_FILEPERMISSION_READONLY)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
} else { \
- result=TARGET_NATIVE_ERROR; \
+ result = TARGET_NATIVE_ERROR; \
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_SET_MODE_READONLY
+ #define TARGET_NATIVE_FILE_SET_MODE_READONLY(filename,result) \
+ CP_FILE_SET_MODE_READONLY(filename,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_EXISTS
* Purpose : check if file exists
-* Input : -
-* Output : -
+* Input : filename - filename
+* Output : result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_FILE_EXISTS
#include <sys/types.h>
#include <sys/stat.h>
@@ -558,20 +858,27 @@
do { \
struct stat __statBuffer; \
\
-
result=(stat(filename,&__statBuffer)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+ result =
(stat(filename,&__statBuffer)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_EXISTS
+ #define TARGET_NATIVE_FILE_EXISTS(filename,result) \
+ CP_FILE_EXISTS(filename,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_IS_FILE
* Purpose : check if directory entry is a file
-* Input : -
-* Output : -
+* Input : filename - filename
+* Output : result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_FILE_IS_FILE
#include <sys/types.h>
#include <sys/stat.h>
@@ -580,20 +887,27 @@
do { \
struct stat __statBuffer; \
\
- result=((stat(filename,&__statBuffer)==0) &&
(S_ISREG(__statBuffer.st_mode)))?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+ result = ((stat(filename,&__statBuffer)==0) &&
(S_ISREG(__statBuffer.st_mode)))?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_IS_FILE
+ #define TARGET_NATIVE_FILE_IS_FILE(filename,result) \
+ CP_FILE_IS_FILE(filename,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_IS_DIRECTORY
* Purpose : check if directory entry is a directory
-* Input : -
-* Output : -
+* Input : filename - filename
+* Output : result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_FILE_IS_DIRECTORY
#include <sys/types.h>
#include <sys/stat.h>
@@ -602,20 +916,28 @@
do { \
struct stat __statBuffer; \
\
- result=((stat(filename,&__statBuffer)==0) &&
(S_ISDIR(__statBuffer.st_mode)))?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+ result = ((stat(filename,&__statBuffer)==0) &&
(S_ISDIR(__statBuffer.st_mode)))?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_IS_DIRECTORY
+ #define TARGET_NATIVE_FILE_IS_DIRECTORY(filename,result) \
+ CP_FILE_IS_DIRECTORY(filename,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_GET_LAST_MODIFIED
* Purpose : get last modification time of file (milliseconds)
-* Input : -
-* Output : -
+* Input : filename - filename
+* Output : time - time [ms]
+* result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_FILE_GET_LAST_MODIFIED
#include <sys/types.h>
#include <sys/stat.h>
@@ -624,28 +946,36 @@
do { \
struct stat __statBuffer; \
\
- time=TARGET_NATIVE_MATH_INT_INT64_CONST_0; \
+ 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; \
+ result = TARGET_NATIVE_OK; \
} else { \
- result=TARGET_NATIVE_ERROR; \
+ result = TARGET_NATIVE_ERROR; \
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_GET_LAST_MODIFIED
+ #define TARGET_NATIVE_FILE_GET_LAST_MODIFIED(filename,time,result) \
+ CP_FILE_GET_LAST_MODIFIED(filename,time,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_SET_LAST_MODIFIED
* Purpose : set last modification time of file (milliseconds)
-* Input : -
-* Output : -
+* Input : filename - filename
+* time - time [ms]
+* Output : result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_FILE_SET_LAST_MODIFIED
#include <sys/types.h>
#include <sys/stat.h>
@@ -674,51 +1004,73 @@
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_SET_LAST_MODIFIED
+ #define TARGET_NATIVE_FILE_SET_LAST_MODIFIED(filename,time,result) \
+ CP_FILE_SET_LAST_MODIFIED(filename,time,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_DELETE
* Purpose : delete a file,link or directory
-* Input : -
-* Output : -
+* Input : filename - filename
+* Output : result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#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
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_DELETE
+ #define TARGET_NATIVE_FILE_DELETE(filename,result) \
+ CP_FILE_DELETE(filename,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_RENAME
* Purpose : delete a file, link or directory
-* Input : -
-* Output : -
+* Input : oldfilename - old filename
+* newfilename - new filename
+* Output : result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#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
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_RENAME
+ #define TARGET_NATIVE_FILE_RENAME(oldfilename,newfilename,result) \
+ CP_FILE_RENAME(oldfilename,newfilename,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_MAKE_DIR
* Purpose : create new directory
* Input : name - directory name
-* Output : result - 1 if successful, 0 otherwise
+* Output : result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_FILE_MAKE_DIR
#include <sys/stat.h>
#define TARGET_NATIVE_FILE_MAKE_DIR(name,result) \
@@ -726,17 +1078,25 @@
result=((mkdir(name,(S_IRWXO|S_IRWXG|S_IRWXU))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR);
\
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_MAKE_DIR
+ #define TARGET_NATIVE_FILE_MAKE_DIR(name,result) \
+ CP_FILE_MAKE_DIR(name,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_GET_CWD
* Purpose : get current working directory
-* Input : -
-* Output : -
+* Input : maxPathLength - max. length of path
+* Output : path - path
+* result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_FILE_GET_CWD
#include <unistd.h>
#define TARGET_NATIVE_FILE_GET_CWD(path,maxPathLength,result) \
@@ -744,37 +1104,77 @@
result=(getcwd(path,maxPathLength)!=NULL)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_GET_CWD
+ #define TARGET_NATIVE_FILE_GET_CWD(path,maxPathLength,result) \
+ CP_FILE_GET_CWD(path,maxPathLength,result)
+#endif
+#endif /* NEW_CP */
+
+/***********************************************************************\
+* Name : TARGET_NATIVE_FILE_CHANGE_DIR
+* Purpose : change current working directory
+* Input : path - pathname
+* Output : result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
+* Return : -
+* Side-effect: unknown
+* Notes : -
+\***********************************************************************/
+
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_FILE_CHANGE_DIR
+ #include <unistd.h>
+ #define TARGET_NATIVE_FILE_CHANGE_DIR(path,result) \
+ do {\
+ result=(chdir(path)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+ } while (0)
+#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_CHANGE_DIR
+ #define TARGET_NATIVE_FILE_CHANGE_DIR(path,result) \
+ CP_FILE_CHANGE_DIR(path,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_OPEN_DIR
* Purpose : open directory for reading entries.
-* Input : -
+* Input : pathname - pathname
* Output : handle - handle if not error, NULL otherwise
+* result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_FILE_OPEN_DIR
#include <sys/types.h>
#include <dirent.h>
- #define TARGET_NATIVE_FILE_OPEN_DIR(filename,handle,result) \
+ #define TARGET_NATIVE_FILE_OPEN_DIR(pathname,handle,result) \
do { \
- handle=(void*)opendir(filename); \
+ handle=(void*)opendir(pathname); \
result=(handle!=NULL)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while(0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_OPEN_DIR
+ #define TARGET_NATIVE_FILE_OPEN_DIR(pathname,handle,result) \
+ CP_FILE_OPEN_DIR(pathname,handle,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_CLOSE_DIR
* Purpose : close directory
-* Input : -
-* Output : -
+* Input : handle - directory handle
+* Output : result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_FILE_CLOSE_DIR
#include <sys/types.h>
#include <dirent.h>
@@ -784,18 +1184,26 @@
result=TARGET_NATIVE_OK; \
} while(0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_CLOSE_DIR
+ #define TARGET_NATIVE_FILE_CLOSE_DIR(handle,result) \
+ CP_FILE_CLOSE_DIR(handle,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_READ_DIR
* Purpose : read directory entry
* Input : -
-* Output : -
+* Output : name - name
+* result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
-/* XXX ??? name als buffer? */
+#ifndef NEW_CP
+//NYI name as buffer?
#ifndef TARGET_NATIVE_FILE_READ_DIR
#include <sys/types.h>
#include <dirent.h>
@@ -803,38 +1211,55 @@
do { \
struct dirent *__direntBuffer; \
\
- name=NULL; \
+ name = NULL; \
\
__direntBuffer=readdir((DIR*)handle); \
if (__direntBuffer!=NULL) { \
- name=__direntBuffer->d_name; \
- result=TARGET_NATIVE_OK; \
+ name = __direntBuffer->d_name; \
+ result = TARGET_NATIVE_OK; \
} else { \
- result=TARGET_NATIVE_ERROR; \
+ result = TARGET_NATIVE_ERROR; \
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_READ_DIR
+ #define TARGET_NATIVE_FILE_READ_DIR(handle,name,result) \
+ CP_FILE_READ_DIR(handle,name,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FILE_FSYNC
* Purpose : do filesystem sync
-* Input : -
-* Output : -
+* Input : filedescriptor - file descriptor
+* Output : result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
* Return : -
* Side-effect: unknown
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_FILE_FSYNC
#define TARGET_NATIVE_FILE_FSYNC(filedescriptor,result) \
do { \
- result=(fsync(filedescriptor)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+ result =
(fsync(filedescriptor)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while(0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_FILE_FSYNC
+ #define TARGET_NATIVE_FILE_FSYNC(filedescriptor,result) \
+ CP_FILE_FILE_FSYNC(filedescriptor,result)
+#endif
+#endif /* NEW_CP */
/***************************** Functions *******************************/
#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
}
#endif
@@ -842,3 +1267,4 @@
/* end of file */
+
diff -ruN --exclude='.*' --exclude='Entries*' --exclude=Repository
--exclude=Root --exclude 'target_generic_math_*'
classpath.org/native/target/generic/target_generic_io.c
classpath/native/target/generic/target_generic_io.c
--- classpath.org/native/target/generic/target_generic_io.c Thu Jan 1
01:00:00 1970
+++ classpath/native/target/generic/target_generic_io.c Fri Oct 8 11:08:29 2004
@@ -0,0 +1,114 @@
+/* target_generic_io.c - Native methods generic I/O 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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 definotions of I/O functions
+Systems : all
+*/
+
+/****************************** Includes *******************************/
+/* do not move; needed here because of some macro definitions */
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#include "target_native.h"
+
+#include "target_native_io.h"
+
+/****************** Conditional compilation switches *******************/
+
+/***************************** Constants *******************************/
+
+/***************************** Datatypes *******************************/
+
+/***************************** Variables *******************************/
+
+/****************************** Macros *********************************/
+
+/***************************** Functions *******************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef TARGET_NATIVE_IO_PRINT_GENERIC
+int targetGenericIO_printf(const char *Format, ...)
+{
+ va_list Arguments;
+ int n;
+
+ assert(Format!=NULL);
+
+ va_start(Arguments,Format);
+ n=vprintf(Format,Arguments);
+ va_end(Arguments);
+
+ /* TEMPORARY: make sure new Unix_printf works like old jprint */
+ fflush(stdout);
+
+ return(n);
+}
+#endif /* TARGET_NATIVE_IO_PRINT_GENERIC */
+
+#ifdef TARGET_NATIVE_IO_PRINT_ERROR_GENERIC
+int targetGenericIO_printf_stderr(const char *Format, ...)
+{
+ va_list Arguments;
+ int n;
+
+ assert(Format!=NULL);
+
+ va_start(Arguments,Format);
+ n=vfprintf(stderr,Format,Arguments);
+ va_end(Arguments);
+
+ /* we need to flush stdout since otherwise stderr is not displayed */
+ fflush(stderr);
+
+ return(n);
+}
+#endif /* TARGET_NATIVE_IO_PRINT_ERROR_GENERIC */
+
+#ifdef __cplusplus
+}
+#endif
+
+/* end of file */
diff -ruN --exclude='.*' --exclude='Entries*' --exclude=Repository
--exclude=Root --exclude 'target_generic_math_*'
classpath.org/native/target/generic/target_generic_io.h
classpath/native/target/generic/target_generic_io.h
--- classpath.org/native/target/generic/target_generic_io.h Mon Mar 29
09:07:40 2004
+++ classpath/native/target/generic/target_generic_io.h Fri Oct 8 11:08:18 2004
@@ -1,4 +1,4 @@
-/* generic_math_int64.h - Native methods for 64bit math operations
+/* target_generic_io.h - Native methods for generic I/O operations
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -57,6 +57,10 @@
#include "target_native.h"
+#ifdef NEW_CP
+#include "../posix/target_posix_io.h"
+#endif
+
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
@@ -67,12 +71,178 @@
/****************************** Macros *********************************/
+/***********************************************************************\
+* Name : TARGET_NATIVE_IO_READ_STDIN
+* Purpose : read data from stdin
+* Input : -
+* Output : -
+* Return : -
+* Side-effect: unknown
+* Notes : -
+\***********************************************************************/
+
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_IO_READ_STDIN
+ #include <unistd.h>
+ #define TARGET_NATIVE_IO_READ_STDIN(buffer,length,bytesRead,result) \
+ do { \
+ bytesRead=read(0,buffer,length); \
+ result=(bytesRead!=-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+ } while (0)
+#endif
+#else /* NEW_CP */
+ #define TARGET_NATIVE_IO_READ_STDIN(buffer,length,bytesWritten,result) \
+ CP_IO_READ_STDIN(buffer,length,bytesWritten,result)
+#endif /* NEW_CP */
+
+/***********************************************************************\
+* Name : TARGET_NATIVE_IO_WRITE_STDOUT
+* Purpose : write data to stdout
+* Input : -
+* Output : -
+* Return : -
+* Side-effect: unknown
+* Notes : -
+\***********************************************************************/
+
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_IO_WRITE_STDOUT
+ #include <unistd.h>
+ #define TARGET_NATIVE_IO_WRITE_STDOUT(buffer,length,bytesWritten,result) \
+ do { \
+ bytesWritten=write(1,buffer,length); \
+ result=(bytesWritten!=-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+ } while (0)
+#endif
+#else /* NEW_CP */
+ #define TARGET_NATIVE_IO_WRITE_STDOUT(buffer,length,bytesWritten,result) \
+ CP_IO_WRITE_STDOUT(buffer,length,bytesWritten,result)
+#endif /* NEW_CP */
+
+/***********************************************************************\
+* Name : write data to stderr
+* Purpose : write data to stderr
+* Input : -
+* Output : -
+* Return : -
+* Side-effect: unknown
+* Notes : -
+\***********************************************************************/
+
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_IO_WRITE_STDERR
+ #include <unistd.h>
+ #define TARGET_NATIVE_IO_WRITE_STDERR(buffer,length,bytesWritten,result) \
+ do { \
+ bytesWritten=write(2,buffer,length); \
+ result=(bytesWritten!=-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
+ } while (0)
+#endif
+#else /* NEW_CP */
+ #define TARGET_NATIVE_IO_WRITE_STDERR(buffer,length,bytesWritten,result) \
+ CP_IO_WRITE_STDERR(buffer,length,bytesWritten,result)
+#endif /* NEW_CP */
+
+/*---------------------------------------------------------------------*/
+
+/***********************************************************************\
+* Name : TARGET_NATIVE_IO_PRINT
+* Purpose : print formated string to stdout
+* Input : format - format string (like printf)
+* args - optional arguments
+* Output : -
+* Return : number of characters printed
+* Side-effect: unknown
+* Notes : Even if printf() is an ANSI-C function a macro is used
+* to be able to use some other output channels than stdout
+* (e. g. a file or a serial port).
+*
+* Hint: for non-gcc compilers only then name is defined and
+* a function is inserted, because of variable number of
+* arguments. Only the preprocessor of gcc support a
+* feature for defining macros with variable parameters. To
+* be able to use an other compiler the macro only replaces
+* the name with some function implementing the output of a
+* string with variable parameters (like printf)
+\***********************************************************************/
+
+/* __PUBLIC_BEGIN__ */
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_IO_PRINT
+/* still not active, because of strange macro problem
x=(TARGET_NATIVE_IO_PRINT_ERROR(...),b) */
+ #ifdef x__GNUC__
+ #include <stdio.h>
+ #define TARGET_NATIVE_IO_PRINT(format,args...) \
+ fprintf(stdout,format, ## args)
+ #else
+ #define TARGET_NATIVE_IO_PRINT_GENERIC
+ #define TARGET_NATIVE_IO_PRINT targetGenericIO_printf
+ #endif
+#endif
+#else /* NEW_CP */
+ #define TARGET_NATIVE_IO_PRINT \
+ CP_IO_PRINT
+#endif /* NEW_CP */
+/* __PUBLIC_END__ */
+
+/***********************************************************************\
+* Name : TARGET_NATIVE_IO_PRINT_ERROR
+* Purpose : print formated string to stderr
+* Input : format - format string (like printf)
+* args - optional arguments
+* Output : -
+* Return : number of characters printed
+* Side-effect: unknown
+* Notes : Even if printf() is an ANSI-C function a macro is used
+* to be able to use some other output channels than stderr
+* (e. g. a file or a serial port).
+*
+* Hint: for non-gcc compilers only then name is defined and
+* a function is inserted, because of variable number of
+* arguments. Only the preprocessor of gcc support a
+* feature for defining macros with variable parameters. To
+* be able to use an other compiler the macro only replaces
+* the name with some function implementing the output of a
+* string with variable parameters (like printf)
+\***********************************************************************/
+
+/* __PUBLIC_BEGIN__ */
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_IO_PRINT_ERROR
+/* still not active, because of strange macro problem
x=(TARGET_NATIVE_IO_PRINT_ERROR(...),b) */
+ #ifdef x__GNUC__
+ #include <stdio.h>
+ #define TARGET_NATIVE_IO_PRINT_ERROR(format,args...) \
+ fprintf(stderr,format, ## args)
+ #else
+ #define TARGET_NATIVE_IO_PRINT_ERROR_GENERIC
+ #define TARGET_NATIVE_IO_PRINT_ERROR targetGenericIO_printf_stderr
+ #endif
+#endif
+#else /* NEW_CP */
+ #define TARGET_NATIVE_IO_PRINT_ERROR \
+ CP_IO_PRINT_ERROR
+#endif /* NEW_CP */
+/* __PUBLIC_END__ */
+
/***************************** Functions *******************************/
#ifdef __cplusplus
-extern "C"
+extern "C" {
#endif
+/* __PUBLIC_BEGIN__ */
+#ifdef TARGET_NATIVE_IO_PRINT_GENERIC
+int targetGenericIO_printf(const char *Format, ...);
+#endif /* TARGET_NATIVE_IO_PRINT_GENERIC */
+/* __PUBLIC_END__ */
+
+/* __PUBLIC_BEGIN__ */
+#ifdef TARGET_NATIVE_IO_PRINT_ERROR_GENERIC
+int targetGenericIO_printf_stderr(const char *Format, ...);
+#endif /* TARGET_NATIVE_IO_PRINT_ERROR_GENERIC */
+/* __PUBLIC_END__ */
+
#ifdef __cplusplus
}
#endif
diff -ruN --exclude='.*' --exclude='Entries*' --exclude=Repository
--exclude=Root --exclude 'target_generic_math_*'
classpath.org/native/target/generic/target_generic_math.h
classpath/native/target/generic/target_generic_math.h
--- classpath.org/native/target/generic/target_generic_math.h Thu Jan 1
01:00:00 1970
+++ classpath/native/target/generic/target_generic_math.h Thu Sep 30
11:40:42 2004
@@ -0,0 +1,348 @@
+/* target_generic_misc.h - Native methods for generic misc 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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__
+#define __TARGET_GENERIC_MATH__
+
+/* check if target_native_math.h included */
+#ifndef __TARGET_NATIVE_MATH__
+ #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 *******************************/
+#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
+
+#ifndef TARGET_NATIVE_MATH_INT_UINT64_CONST_0
+ #define TARGET_NATIVE_MATH_INT_UINT64_CONST_0 0LL
+#endif
+#ifndef TARGET_NATIVE_MATH_INT_UINT64_CONST_1
+ #define TARGET_NATIVE_MATH_INT_UINT64_CONST_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
+
+#ifndef TARGET_NATIVE_MATH_INT_INT64_TO_UINT64
+ #define TARGET_NATIVE_MATH_INT_INT64_TO_UINT64(v) ((jlong)(v))
+#endif
+#ifndef TARGET_NATIVE_MATH_INT_UINT64_TO_INT64
+ #define TARGET_NATIVE_MATH_INT_UINT64_TO_INT64(v) ((jlong)(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) & 0xFFFFffff00000000LL) >> 32; \
+ (low) =((v) & 0x00000000FFFFffffLL) >> 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) & 0xFFFFffff00000000LL) >> 32; \
+ (low) =((v) & 0x00000000FFFFffffLL) >> 0; \
+ } while (0)
+#endif
+
+/*---------------------------------------------------------------------*/
+
+/* NYI: it would be nice to check if isnan(), isinf(), finite() is
+available on the system, e. g. use HAVE_ISNAN, HAVE_ISINF, HAVE_FINITE
+*/
+
+/* __PUBLIC_BEGIN__ */
+
+/* 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)!=0)
+#endif
+#ifndef TARGET_NATIVE_MATH_FLOAT_FLOAT_POS_ISINF
+ #include <math.h>
+ #define TARGET_NATIVE_MATH_FLOAT_FLOAT_POS_ISINF(f) (isinf(f)>0)
+#endif
+#ifndef TARGET_NATIVE_MATH_FLOAT_FLOAT_NEG_ISINF
+ #include <math.h>
+ #define TARGET_NATIVE_MATH_FLOAT_FLOAT_NEG_ISINF(f) (isinf(f)<0)
+#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)!=0)
+#endif
+#ifndef TARGET_NATIVE_MATH_FLOAT_DOUBLE_POS_ISINF
+ #include <math.h>
+ #define TARGET_NATIVE_MATH_FLOAT_DOUBLE_POS_ISINF(d) (isinf(d)>0)
+#endif
+#ifndef TARGET_NATIVE_MATH_FLOAT_DOUBLE_NEG_ISINF
+ #include <math.h>
+ #define TARGET_NATIVE_MATH_FLOAT_DOUBLE_NEG_ISINF(d) (isinf(d)<0)
+#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
+
+/* __PUBLIC_END__ */
+
+/***************************** Functions *******************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TARGET_GENERIC_MATH__ */
+
+/* end of file */
+
diff -ruN --exclude='.*' --exclude='Entries*' --exclude=Repository
--exclude=Root --exclude 'target_generic_math_*'
classpath.org/native/target/generic/target_generic_memory.h
classpath/native/target/generic/target_generic_memory.h
--- classpath.org/native/target/generic/target_generic_memory.h Thu Jan 1
01:00:00 1970
+++ classpath/native/target/generic/target_generic_memory.h Thu Sep 30
11:40:42 2004
@@ -0,0 +1,210 @@
+/* taret_generic_memory.h - Native methods for generic memory 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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 memory functions
+Systems : all
+*/
+
+#ifndef __TARGET_GENERIC_MEMORY__
+#define __TARGET_GENERIC_MEMORY__
+
+/* check if target_native_io.h included */
+#ifndef __TARGET_NATIVE_MEMORY__
+ #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"
+
+#ifdef NEW_CP
+#include "../posix/target_posix_memory.h"
+#endif
+
+/****************** Conditional compilation switches *******************/
+
+/***************************** Constants *******************************/
+
+/***************************** Datatypes *******************************/
+
+/***************************** Variables *******************************/
+
+/****************************** Macros *********************************/
+
+/***********************************************************************\
+* Name : TARGET_NATIVE_MEMORY_ALLOC
+* Purpose : allocate memory
+* Input : type - type definition (use for cast)
+* size - size of memory (in bytes)
+* Output : p - allocated memory or NULL if insufficient memory
+* Return : -
+* Side-effect: unknown
+* Notes : -
+\***********************************************************************/
+
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_MEMORY_ALLOC
+ #include <string.h>
+ #define TARGET_NATIVE_MEMORY_ALLOC(p,type,size) \
+ do { \
+ p=(type)malloc(size); \
+ } while(0)
+#endif
+#else /* NEW_CP */
+ #define TARGET_NATIVE_MEMORY_ALLOC(p,type,size) \
+ CP_MEMORY_ALLOC(p,type,size)
+#endif /* NEW_CP */
+
+/***********************************************************************\
+* Name : TARGET_NATIVE_MEMORY_REALLOC
+* Purpose : re-allocate memory (decrease/increase size)
+* Input : type - type definition (use for cast)
+* oldSize - old size of memory (in bytes)
+* newSize - new size of memory (in bytes)
+* Output : p - allocated memory or NULL if insufficient memory
+* Return : -
+* Side-effect: unknown
+* Notes : -
+\***********************************************************************/
+
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_MEMORY_REALLOC
+ #include <string.h>
+ #define TARGET_NATIVE_MEMORY_REALLOC(p,type,oldSize,newSize) \
+ do { \
+ p=(type)realloc(p,newSize); \
+ } while(0)
+#endif
+#else /* NEW_CP */
+ #define TARGET_NATIVE_MEMORY_REALLOC(p,type,oldSize,newSize) \
+ CP_MEMORY_REALLOC(p,type,oldSize,newSize)
+#endif /* NEW_CP */
+
+/***********************************************************************\
+* Name : TARGET_NATIVE_MEMORY_FREE
+* Purpose : free memory
+* Input : p - pointer to memory to free
+* Output : -
+* Return : -
+* Side-effect: unknown
+* Notes : -
+\***********************************************************************/
+
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_MEMORY_FREE
+ #include <string.h>
+ #include <assert.h>
+ #define TARGET_NATIVE_MEMORY_FREE(p) \
+ do { \
+ assert(p!=NULL); \
+ free(p); \
+ } while(0)
+#endif
+#else /* NEW_CP */
+ #define TARGET_NATIVE_MEMORY_FREE(p) \
+ CP_MEMORY_FREE(p)
+#endif /* NEW_CP */
+
+/***********************************************************************\
+* Name : TARGET_NATIVE_MEMORY_FILL
+* Purpose : fill memory
+* Input : p - pointer to memory to fill
+* value - value for fill
+* size - size to fill
+* Output : -
+* Return : -
+* Side-effect: unknown
+* Notes : -
+\***********************************************************************/
+
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_MEMORY_FILL
+ #include <string.h>
+ #define TARGET_NATIVE_MEMORY_FILL(p,value,size) \
+ do { \
+ memset(p,value,size); \
+ } while(0)
+#endif
+#else /* NEW_CP */
+ #define TARGET_NATIVE_MEMORY_FILL(p,value,size) \
+ CP_MEMORY_FILL(p,value,size)
+#endif /* NEW_CP */
+
+/***********************************************************************\
+* Name : TARGET_NATIVE_MEMORY_COPY
+* Purpose : copy memory
+* Input : source - pointer to memory source
+* destination - pointer to memory destination
+* size - size to copy (bytes)
+* Output : -
+* Return : -
+* Side-effect: unknown
+* Notes : -
+\***********************************************************************/
+
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_MEMORY_COPY
+ #include <string.h>
+ #define TARGET_NATIVE_MEMORY_COPY(source,destination,size) \
+ do { \
+ memmove(destination,source,size); \
+ } while(0)
+#endif
+#else /* NEW_CP */
+ #define TARGET_NATIVE_MEMORY_COPY(source,destination,size) \
+ CP_MEMORY_COPY(source,destination,size)
+#endif /* NEW_CP */
+
+/***************************** Functions *******************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TARGET_GENERIC_MEMORY__ */
+
+/* end of file */
diff -ruN --exclude='.*' --exclude='Entries*' --exclude=Repository
--exclude=Root --exclude 'target_generic_math_*'
classpath.org/native/target/generic/target_generic_misc.h
classpath/native/target/generic/target_generic_misc.h
--- classpath.org/native/target/generic/target_generic_misc.h Tue Aug 31
23:06:48 2004
+++ classpath/native/target/generic/target_generic_misc.h Thu Sep 30
11:40:42 2004
@@ -1,4 +1,4 @@
-/* generic_math_int64.h - Native methods for 64bit math operations
+/* target_gneric_misc.h - Native methods for generic misc operations
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -57,6 +57,19 @@
#include "target_native.h"
+/*
+#ifndef HAVE_SNPRINTF
+ #warning Function snprintf() not available - use insecure sprintf()!
+#endif
+#ifndef HAVE_VSNPRINTF
+ #warning Function vsnprintf() not available - use insecure vsprintf()!
+#endif
+*/
+
+#ifdef NEW_CP
+#include "../posix/target_posix_misc.h"
+#endif
+
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
@@ -68,8 +81,8 @@
/****************************** Macros *********************************/
/***********************************************************************\
-* Name : TARGET_NATIVE_MISC_FORMAT_STRING<n>
-* Purpose : format a string (with a fixed number of) arguments
+* Name : TARGET_NATIVE_MISC_FORMAT_STRING
+* Purpose : format a string with arguments
* Input : buffer - buffer for string
* bufferSize - size of buffer
* format - format string (like printf)
@@ -77,85 +90,238 @@
* Output : -
* Return : -
* Side-effect: unknown
-* Notes : - this is a "safe" macro to format string; buffer-
+* Notes : - this macro can only be used with a GNU gcc (CPP)
+* - 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 NEW_CP
+#ifndef TARGET_NATIVE_MISC_FORMAT_STRING
+ #if defined(__GNUC__) || defined(CPP_VARARGS)
+ #include <stdio.h>
+ #ifdef HAVE_SNPRINTF
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING(buffer,bufferSize,format,args...) \
+ do { \
+ snprintf(buffer,bufferSize,format, ## args); \
+ } while (0)
+ #else
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING(buffer,bufferSize,format,args...) \
+ do { \
+ sprintf(buffer,format, ## args); \
+ } while (0)
+ #endif
+ #endif
+#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_MISC_FORMAT_STRING
+ #if defined(__GNUC__) || defined(CPP_VARARGS)
+ #define TARGET_NATIVE_MISC_FORMAT_STRING(buffer,bufferSize,format,args...)
\
+ CP_MISC_FORMAT_STRING(buffer,bufferSize,format, ## args)
+ #endif
+#endif
+#endif /* NEW_CP */
+
+/***********************************************************************\
+* 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!)
+\***********************************************************************/
+
+#ifndef NEW_CP
#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)
+ #include <stdio.h>
+ #ifdef HAVE_SNPRINTF
+ #define TARGET_NATIVE_MISC_FORMAT_STRING0(buffer,bufferSize,format) \
+ do { \
+ snprintf(buffer,bufferSize,format); \
+ } while (0)
+ #else
+ #define TARGET_NATIVE_MISC_FORMAT_STRING0(buffer,bufferSize,format) \
+ do { \
+ sprintf(buffer,format); \
+ } while (0)
+ #endif
#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)
+ #ifdef HAVE_SNPRINTF
+ #define TARGET_NATIVE_MISC_FORMAT_STRING1(buffer,bufferSize,format,arg1) \
+ do { \
+ snprintf(buffer,bufferSize,format,arg1); \
+ } while (0)
+ #else
+ #define TARGET_NATIVE_MISC_FORMAT_STRING1(buffer,bufferSize,format,arg1) \
+ do { \
+ sprintf(buffer,format,arg1); \
+ } while (0)
+ #endif
#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)
+ #ifdef HAVE_SNPRINTF
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING2(buffer,bufferSize,format,arg1,arg2) \
+ do { \
+ snprintf(buffer,bufferSize,format,arg1,arg2); \
+ } while (0)
+ #else
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING2(buffer,bufferSize,format,arg1,arg2) \
+ do { \
+ sprintf(buffer,format,arg1,arg2); \
+ } while (0)
+ #endif
#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)
+ #ifdef HAVE_SNPRINTF
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING3(buffer,bufferSize,format,arg1,arg2,arg3) \
+ do { \
+ snprintf(buffer,bufferSize,format,arg1,arg2,arg3); \
+ } while (0)
+ #else
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING3(buffer,bufferSize,format,arg1,arg2,arg3) \
+ do { \
+ sprintf(buffer,format,arg1,arg2,arg3); \
+ } while (0)
+ #endif
#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)
+ #ifdef HAVE_SNPRINTF
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING4(buffer,bufferSize,format,arg1,arg2,arg3,arg4)
\
+ do { \
+ snprintf(buffer,bufferSize,format,arg1,arg2,arg3,arg4); \
+ } while (0)
+ #else
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING4(buffer,bufferSize,format,arg1,arg2,arg3,arg4)
\
+ do { \
+ sprintf(buffer,format,arg1,arg2,arg3,arg4); \
+ } while (0)
+ #endif
#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)
+ #ifdef HAVE_SNPRINTF
+ #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)
+ #else
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING5(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5)
\
+ do { \
+ sprintf(buffer,format,arg1,arg2,arg3,arg4,arg5); \
+ } while (0)
+ #endif
#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)
+ #ifdef HAVE_SNPRINTF
+ #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)
+ #else
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING6(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5,arg6)
\
+ do { \
+ sprintf(buffer,format,arg1,arg2,arg3,arg4,arg5,arg6); \
+ } while (0)
+ #endif
#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)
+ #ifdef HAVE_SNPRINTF
+ #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)
+ #else
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING7(buffer,bufferSize,format,arg1,arg2,arg3,arg14,arg5,arg6,arg7)
\
+ do { \
+ sprintf(buffer,format,arg1,arg2,arg3,arg4,arg5,arg6,arg7); \
+ } while (0)
+ #endif
#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)
+ #ifdef HAVE_SNPRINTF
+ #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)
+ #else
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING8(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)
\
+ do { \
+ sprintf(buffer,format,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); \
+ } while (0)
+ #endif
#endif
#ifndef TARGET_NATIVE_MISC_FORMAT_STRING9
#include <stdarg.h>
+ #ifdef HAVE_SNPRINTF
+ #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)
+ #else
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING9(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
\
+ do { \
+ sprintf(buffer,format,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); \
+ } while (0)
+ #endif
+#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_MISC_FORMAT_STRING0
+ #define TARGET_NATIVE_MISC_FORMAT_STRING0(buffer,bufferSize,format) \
+ CP_MISC_FORMAT_STRING0(buffer,bufferSize,format)
+#endif
+#ifndef TARGET_NATIVE_MISC_FORMAT_STRING1
+ #define TARGET_NATIVE_MISC_FORMAT_STRING1(buffer,bufferSize,format,arg1) \
+ CP_MISC_FORMAT_STRING1(buffer,bufferSize,format,arg1)
+#endif
+#ifndef TARGET_NATIVE_MISC_FORMAT_STRING2
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING2(buffer,bufferSize,format,arg1,arg2) \
+ CP_MISC_FORMAT_STRING2(buffer,bufferSize,format,arg1,arg2)
+#endif
+#ifndef TARGET_NATIVE_MISC_FORMAT_STRING3
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING3(buffer,bufferSize,format,arg1,arg2,arg3) \
+ CP_MISC_FORMAT_STRING3(buffer,bufferSize,format,arg1,arg2,arg3)
+#endif
+#ifndef TARGET_NATIVE_MISC_FORMAT_STRING4
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING4(buffer,bufferSize,format,arg1,arg2,arg3,arg4)
\
+ CP_MISC_FORMAT_STRING4(buffer,bufferSize,format,arg1,arg2,arg3,arg)
+#endif
+#ifndef TARGET_NATIVE_MISC_FORMAT_STRING5
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING5(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5)
\
+ CP_MISC_FORMAT_STRING5(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5)
+#endif
+#ifndef TARGET_NATIVE_MISC_FORMAT_STRING6
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING6(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5,arg6)
\
+
CP_MISC_FORMAT_STRING6(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5,arg6)
+#endif
+#ifndef TARGET_NATIVE_MISC_FORMAT_STRING7
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING7(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
\
+
CP_MISC_FORMAT_STRING7(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
+#endif
+#ifndef TARGET_NATIVE_MISC_FORMAT_STRING8
+ #define
TARGET_NATIVE_MISC_FORMAT_STRING8(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)
\
+
CP_MISC_FORMAT_STRING8(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)
+#endif
+#ifndef TARGET_NATIVE_MISC_FORMAT_STRING9
#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)
+
CP_MISC_FORMAT_STRING9(buffer,bufferSize,format,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_FORMAT_STRING_ELLIPSE
@@ -177,15 +343,84 @@
#ifndef TARGET_NATIVE_MISC_FORMAT_STRING_ELLIPSE
#include <stdarg.h>
- #define TARGET_NATIVE_FORMAT_STRING_ELLIPSE(buffer,bufferSize,format) \
+ #ifdef HAVE_VSNPRINTF
+ #define TARGET_NATIVE_MISC_FORMAT_STRING_ELLIPSE(buffer,bufferSize,format)
\
+ do { \
+ va_list __arguments; \
+ \
+ va_start(__arguments,format); \
+ vsnprintf(buffer,bufferSize,format,__arguments); \
+ va_end(__arguments); \
+ } while (0)
+ #else
+ #define TARGET_NATIVE_MISC_FORMAT_STRING_ELLIPSE(buffer,bufferSize,format)
\
+ do { \
+ va_list __arguments; \
+ \
+ va_start(__arguments,format); \
+ vsprintf(buffer,format,__arguments); \
+ va_end(__arguments); \
+ } while (0)
+ #endif
+#endif
+
+/***********************************************************************\
+* Name : TARGET_NATIVE_MISC_GET_TIMEZONE_STRING
+* Purpose : get timezone string
+* Input : string - buffer for timezone string
+* maxStringLength - max. string length
+* Output : string - timezone string
+* result - TARGET_NATIVE_OK or TARGET_NATIVE_ERROR
+* Return : -
+* Side-effect: unknown
+* Notes : set WITH_TIMEZONE_VARIABLE to timezone variable if not
+* 'timezone' (e. g. Cygwin)
+\***********************************************************************/
+
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_MISC_GET_TIMEZONE_STRING
+ #if TIME_WITH_SYS_TIME
+ #include <sys/time.h>
+ #include <time.h>
+ #else
+ #if HAVE_SYS_TIME_H
+ #include <sys/time.h>
+ #else
+ #include <time.h>
+ #endif
+ #endif
+ #include <string.h>
+ #ifndef WITH_TIMEZONE_VARIABLE
+ #define WITH_TIMEZONE_VARIABLE timezone
+ #endif
+ #define
TARGET_NATIVE_MISC_GET_TIMEZONE_STRING(string,maxStringLength,result) \
do { \
- va_list __arguments; \
+ tzset(); \
\
- va_start(__arguments,format); \
- vsnprintf(buffer,bufferSize,format,__arguments); \
- va_end(__arguments); \
- } while (0)
+ if (strcmp(tzname[0],tzname[1])!=0) \
+ { \
+
result=((strlen(tzname[0])+6)<=maxStringLength)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
+ if (result==TARGET_NATIVE_OK) \
+ { \
+
TARGET_NATIVE_MISC_FORMAT_STRING2(string,maxStringLength,"%s%ld",tzname[0],((WITH_TIMEZONE_VARIABLE%3600)==0)?WITH_TIMEZONE_VARIABLE/3600:WITH_TIMEZONE_VARIABLE);
\
+ } \
+ } \
+ else \
+ { \
+
result=((strlen(tzname[0])+strlen(tzname[1])+6)<=maxStringLength)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
+ if (result==TARGET_NATIVE_OK) \
+ { \
+
TARGET_NATIVE_MISC_FORMAT_STRING3(string,maxStringLength,"%s%ld%s",tzname[0],((WITH_TIMEZONE_VARIABLE%3600)==0)?WITH_TIMEZONE_VARIABLE/3600:WITH_TIMEZONE_VARIABLE,tzname[1]);
\
+ } \
+ } \
+ } while (0)
+#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_MISC_GET_TIMEZONE_STRING
+ #define
TARGET_NATIVE_MISC_GET_TIMEZONE_STRING(string,maxStringLength,result) \
+ CP_MISC_GET_TIMEZONE_STRING(string,maxStringLength,result)
#endif
+#endif /* NEW_CP */
/***************************** Functions *******************************/
diff -ruN --exclude='.*' --exclude='Entries*' --exclude=Repository
--exclude=Root --exclude 'target_generic_math_*'
classpath.org/native/target/generic/target_generic_network.h
classpath/native/target/generic/target_generic_network.h
--- classpath.org/native/target/generic/target_generic_network.h Tue Oct
26 22:26:03 2004
+++ classpath/native/target/generic/target_generic_network.h Tue Oct 12
14:25:19 2004
@@ -1,5 +1,5 @@
-/* target_generic_network.h - Native methods for network operations.
- Copyright (C) 1998, 2004 Free Software Foundation, Inc.
+/* target_generic_network.h - Native methods for generic network operations
+ Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -53,12 +53,26 @@
#include "config.h"
#include <stdlib.h>
+#include <assert.h>
#include "target_native.h"
+#ifdef NEW_CP
+#include "../posix/target_posix_network.h"
+#endif
+
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_NETWORK_IPADDRESS_ANY
+ #define TARGET_NATIVE_NETWORK_IPADDRESS_ANY INADDR_ANY
+#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_IPADDRESS_ANY
+ #define TARGET_NATIVE_NETWORK_IPADDRESS_ANY CP_NETWORK_IPADDRESS_ANY
+#endif
+#endif /* NEW_CP */
/***************************** Datatypes *******************************/
@@ -77,6 +91,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_IPADDRESS_BYTES_TO_INT
#define TARGET_NATIVE_NETWORK_IPADDRESS_BYTES_TO_INT(n0,n1,n2,n3,i) \
do { \
@@ -86,6 +101,12 @@
(((unsigned char)n3) << 0); \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_IPADDRESS_BYTES_TO_INT
+ #define TARGET_NATIVE_NETWORK_IPADDRESS_BYTES_TO_INT(n0,n1,n2,n3,i) \
+ CP_NETWORK_IPADDRESS_BYTES_TO_INT(n0,n1,n2,n3,i)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_INT_TO_IPADDRESS_BYTES
@@ -98,6 +119,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_INT_TO_IPADDRESS_BYTES
#define TARGET_NATIVE_NETWORK_INT_TO_IPADDRESS_BYTES(i,n0,n1,n2,n3) \
do { \
@@ -107,6 +129,12 @@
n3=(i & 0x000000FF) >> 0; \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_INT_TO_IPADDRESS_BYTES
+ #define TARGET_NATIVE_NETWORK_INT_TO_IPADDRESS_BYTES(i,n0,n1,n2,n3) \
+ CP_NETWORK_INT_TO_IPADDRESS_BYTES(i,n0,n1,n2,n3)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_GET_HOSTNAME
@@ -120,6 +148,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_GET_HOSTNAME
#include <unistd.h>
#define TARGET_NATIVE_NETWORK_GET_HOSTNAME(name,maxNameLen,result) \
@@ -128,6 +157,12 @@
name[maxNameLen-1]='\0'; \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_GET_HOSTNAME
+ #define TARGET_NATIVE_NETWORK_GET_HOSTNAME(name,maxNameLen,result) \
+ CP_NETWORK_GET_HOSTNAME(name,maxNameLen,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_GET_HOSTNAME_BY_ADDRESS
@@ -142,7 +177,8 @@
* Notes : -
\***********************************************************************/
-/* XXX NYI??? reentrant? */
+#ifndef NEW_CP
+//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) \
@@ -164,47 +200,88 @@
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_GET_HOSTNAME_BY_ADDRESS
+ #define
TARGET_NATIVE_NETWORK_GET_HOSTNAME_BY_ADDRESS(address,name,maxNameLen,result) \
+ CP_NETWORK_GET_HOSTNAME_BY_ADDRESS(address,name,maxNameLen,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
-* Name : TARGET_NATIVE_NETWORK_GET_HOSTNAME_BY_NAME
+* Name : TARGET_NATIVE_NETWORK_GET_HOSTADDRESS_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
+* Output : addresses - host addresses (array, in host 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
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_NETWORK_GET_HOSTADDRESS_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)) \
+ #ifdef HAVE_GETHOSTBYNAME_R
+ #define
TARGET_NATIVE_NETWORK_GET_HOSTADDRESS_BY_NAME(name,addresses,maxAddressCount,addressCount,result)
\
+ do { \
+ struct hostent __hostEntry; \
+ char __buffer[5000]; \
+ struct hostent *__hostEntryResult; \
+ int __h_errno; \
+ \
+ addressCount = 0; \
+ \
+ if
(gethostbyname_r(name,&__hostEntry,__buffer,sizeof(__buffer),&__hostEntryResult,&__h_errno)
== 0) \
+ { \
+ while ((addressCount<maxAddressCount) &&
(__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)
+ #else
+ #ifdef CPP_HAS_WARNING
+ #warning Using non-thread-safe function gethostbyname() (no
gethostbyname_r() available)
+ #endif
+ #define
TARGET_NATIVE_NETWORK_GET_HOSTADDRESS_BY_NAME(name,addresses,maxAddressCount,addressCount,result)
\
+ do { \
+ struct hostent *__hostEntry; \
+ \
+ addressCount=0; \
+ \
+ __hostEntry = gethostbyname(name); \
+ if (__hostEntry!=NULL) \
{ \
-
addresses[addressCount]=ntohl(*(int*)(__hostEntry->h_addr_list[addressCount]));
\
- addressCount++; \
+ while ((addressCount<maxAddressCount) &&
(__hostEntry->h_addr_list[addressCount]!=NULL)) \
+ { \
+
addresses[addressCount]=ntohl(*(int*)(__hostEntry->h_addr_list[addressCount]));
\
+ addressCount++; \
+ } \
+ result=TARGET_NATIVE_OK; \
} \
- result=TARGET_NATIVE_OK; \
- } \
- else \
- { \
- result=TARGET_NATIVE_ERROR; \
- } \
- } while (0)
+ else \
+ { \
+ result=TARGET_NATIVE_ERROR; \
+ } \
+ } while (0)
+ #endif
+#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_GET_HOSTADDRESS_BY_NAME
+ #define
TARGET_NATIVE_NETWORK_GET_HOSTADDRESS_BY_NAME(name,addresses,maxAddressCount,addressCount,result)
\
+
CP_NETWORK_GET_HOSTADDRESS_BY_NAME(name,addresses,maxAddressCount,addressCount,result)
#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_OPEN_STREAM
@@ -218,17 +295,26 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_OPEN_STREAM
#include <sys/types.h>
- #include <sys/socket.h>
#include <fcntl.h>
+ #include <sys/socket.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; \
+ if (result==TARGET_NATIVE_OK) { \
+ fcntl(socketDescriptor,F_SETFD,FD_CLOEXEC); \
+ } \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_OPEN_STREAM
+ #define TARGET_NATIVE_NETWORK_SOCKET_OPEN_STREAM(socketDescriptor,result) \
+ CP_NETWORK_SOCKET_OPEN_STREAM(socketDescriptor,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_OPEN_DATAGRAM
@@ -242,17 +328,26 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_OPEN_DATAGRAM
#include <sys/types.h>
- #include <sys/socket.h>
#include <fcntl.h>
+ #include <sys/socket.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; \
+ if (result==TARGET_NATIVE_OK) { \
+ fcntl(socketDescriptor,F_SETFD,FD_CLOEXEC); \
+ } \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_OPEN_DATAGRAM
+ #define TARGET_NATIVE_NETWORK_SOCKET_OPEN_DATAGRAM(socketDescriptor,result) \
+ CP_NETWORK_SOCKET_OPEN_DATAGRAM(socketDescriptor,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_CLOSE
@@ -265,6 +360,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_CLOSE
#include <unistd.h>
#define TARGET_NATIVE_NETWORK_SOCKET_CLOSE(socketDescriptor,result) \
@@ -272,6 +368,12 @@
result=(close(socketDescriptor)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_CLOSE
+ #define TARGET_NATIVE_NETWORK_SOCKET_CLOSE(socketDescriptor,result) \
+ CP_NETWORK_SOCKET_CLOSE(socketDescriptor,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_CONNECT
@@ -286,6 +388,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_CONNECT
#include <sys/types.h>
#include <sys/socket.h>
@@ -302,6 +405,12 @@
result=(connect(socketDescriptor,(struct
sockaddr*)&__socketAddress,sizeof(__socketAddress))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_CONNECT
+ #define
TARGET_NATIVE_NETWORK_SOCKET_CONNECT(socketDescriptor,address,port,result) \
+ CP_NETWORK_SOCKET_CONNECT(socketDescriptor,address,port,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_BIND
@@ -316,7 +425,7 @@
* Notes : -
\***********************************************************************/
-/* XXX ??? address in network byte order? */
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_BIND
#include <sys/types.h>
#include <sys/socket.h>
@@ -333,6 +442,12 @@
result=(bind(socketDescriptor,(struct
sockaddr*)&__socketAddress,sizeof(__socketAddress))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_BIND
+ #define
TARGET_NATIVE_NETWORK_SOCKET_BIND(socketDescriptor,address,port,result) \
+ CP_NETWORK_SOCKET_BIND(socketDescriptor,address,port,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_LISTEN
@@ -346,7 +461,8 @@
* Notes : -
\***********************************************************************/
-/* XXX ??? address in network byte order? */
+#ifndef NEW_CP
+//??? address in network byte order?
#ifndef TARGET_NATIVE_NETWORK_SOCKET_LISTEN
#include <sys/socket.h>
#define
TARGET_NATIVE_NETWORK_SOCKET_LISTEN(socketDescriptor,maxQueueLength,result) \
@@ -354,6 +470,12 @@
result=(listen(socketDescriptor,maxQueueLength)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_LISTEN
+ #define
TARGET_NATIVE_NETWORK_SOCKET_LISTEN(socketDescriptor,maxQueueLength,result) \
+ CP_NETWORK_SOCKET_LISTEN(socketDescriptor,maxQueueLength,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_ACCEPT
@@ -366,7 +488,8 @@
* Notes : -
\***********************************************************************/
-/* XXX ??? address in network byte order? */
+#ifndef NEW_CP
+//??? address in network byte order?
#ifndef TARGET_NATIVE_NETWORK_SOCKET_ACCEPT
#include <sys/types.h>
#include <sys/socket.h>
@@ -382,6 +505,12 @@
result=(newSocketDescriptor!=-1)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR; \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_ACCEPT
+ #define
TARGET_NATIVE_NETWORK_SOCKET_ACCEPT(socketDescriptor,newSocketDescriptor,result)
\
+ CP_NETWORK_SOCKET_ACCEPT(socketDescriptor,newSocketDescriptor,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_LOCAL_INFO
@@ -396,6 +525,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_LOCAL_INFO
#include <sys/socket.h>
#include <netinet/in.h>
@@ -411,11 +541,19 @@
result=(getsockname(socketDescriptor,(struct
sockaddr*)&__socketAddress,&__socketAddressLength)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
if (result==TARGET_NATIVE_OK) \
{ \
+ /* make sure all data in __socketAddress has been written to avoid
undefined values */ \
+ assert(__socketAddressLength>=sizeof(__socketAddress)); \
localAddress=ntohl(__socketAddress.sin_addr.s_addr); \
localPort =ntohs(__socketAddress.sin_port); \
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_LOCAL_INFO
+ #define
TARGET_NATIVE_NETWORK_SOCKET_GET_LOCAL_INFO(socketDescriptor,localAddress,localPort,result)
\
+
CP_NETWORK_SOCKET_GET_LOCAL_INFO(socketDescriptor,localAddress,localPort,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_REMOTE_INFO
@@ -430,6 +568,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_REMOTE_INFO
#include <sys/socket.h>
#include <netinet/in.h>
@@ -445,11 +584,19 @@
result=(getpeername(socketDescriptor,(struct
sockaddr*)&__socketAddress,&__socketAddressLength)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
if (result==TARGET_NATIVE_OK) \
{ \
+ /* make sure all data in __socketAddress has been written to avoid
undefined values */ \
+ assert(__socketAddressLength>=sizeof(__socketAddress)); \
remoteAddress=ntohl(__socketAddress.sin_addr.s_addr); \
remotePort =ntohs(__socketAddress.sin_port); \
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_REMOTE_INFO
+ #define
TARGET_NATIVE_NETWORK_SOCKET_GET_REMOTE_INFO(socketDescriptor,remoteAddress,remotePort,result)
\
+
CP_NETWORK_SOCKET_GET_REMOTE_INFO(socketDescriptor,remoteAddress,remotePort,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_AVAILABLE
@@ -463,6 +610,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_AVAILABLE
#include <sys/ioctl.h>
#define
TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_AVAILABLE(socketDescriptor,bytesAvailable,result)
\
@@ -478,6 +626,12 @@
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_AVAILABLE
+ #define
TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_AVAILABLE(socketDescriptor,bytesAvailable,result)
\
+ CP_NETWORK_SOCKET_RECEIVE_AVAILABLE(socketDescriptor,bytesAvailable,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_RECEIVE
@@ -491,20 +645,22 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#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
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_RECEIVE
+ #define
TARGET_NATIVE_NETWORK_SOCKET_RECEIVE(socketDescriptor,buffer,maxLength,bytesReceived)
\
+ CP_NETWORK_SOCKET_RECEIVE(socketDescriptor,buffer,maxLength,bytesReceived)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_WITH_ADDRESS_PORT
@@ -520,6 +676,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_WITH_ADDRESS_PORT
#include <sys/types.h>
#include <sys/socket.h>
@@ -541,6 +698,12 @@
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_WITH_ADDRESS_PORT
+ #define
TARGET_NATIVE_NETWORK_SOCKET_RECEIVE_WITH_ADDRESS_PORT(socketDescriptor,buffer,maxLength,address,port,bytesReceived)
\
+
CP_NETWORK_SOCKET_RECEIVE_WITH_ADDRESS_PORT(socketDescriptor,buffer,maxLength,address,port,bytesReceived)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_SEND
@@ -553,15 +716,22 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#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); \
+ bytesSent=send(socketDescriptor,buffer,length,MSG_NOSIGNAL); \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_SEND
+ #define
TARGET_NATIVE_NETWORK_SOCKET_SEND(socketDescriptor,buffer,length,bytesSent) \
+ CP_NETWORK_SOCKET_SEND(socketDescriptor,buffer,length,bytesSent)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_SEND_WITH_ADDRESS_PORT
@@ -576,6 +746,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_SEND_WITH_ADDRESS_PORT
#include <sys/types.h>
#include <sys/socket.h>
@@ -588,9 +759,15 @@
__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)); \
+ bytesSent=sendto(socketDescriptor,buffer,length,MSG_NOSIGNAL,(struct
sockaddr*)&__socketAddress,sizeof(__socketAddress)); \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_SEND_WITH_ADDRESS_PORT
+ #define
TARGET_NATIVE_NETWORK_SOCKET_SEND_WITH_ADDRESS_PORT(socketDescriptor,buffer,length,address,port,bytesSent)
\
+
CP_NETWORK_SOCKET_SEND_WITH_ADDRESS_PORT(socketDescriptor,buffer,length,address,port,bytesSent)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_TCP_NODELAY
@@ -604,6 +781,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_TCP_NODELAY
#include <sys/types.h>
#include <sys/socket.h>
@@ -616,6 +794,12 @@
result=(setsockopt(socketDescriptor,IPPROTO_TCP,TCP_NODELAY,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_TCP_NODELAY
+ #define
TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_TCP_NODELAY(socketDescriptor,flag,result)
\
+ CP_NETWORK_SOCKET_SET_OPTION_TCP_NODELAY(socketDescriptor,flag,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_LINGER
@@ -630,6 +814,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_LINGER
#include <sys/types.h>
#include <sys/socket.h>
@@ -650,6 +835,12 @@
result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_LINGER,&__linger,sizeof(__linger))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_LINGER
+ #define
TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_LINGER(socketDescriptor,flag,value,result)
\
+ CP_NETWORK_SOCKET_SET_OPTION_SO_LINGER(socketDescriptor,flag,value,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_TIMEOUT
@@ -663,6 +854,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_TIMEOUT
#include <sys/types.h>
#include <sys/socket.h>
@@ -674,6 +866,12 @@
result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_TIMEOUT,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_TIMEOUT
+ #define
TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_TIMEOUT(socketDescriptor,flag,result)
\
+ CP_NETWORK_SOCKET_SET_OPTION_SO_TIMEOUT(socketDescriptor,flag,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_SNDBUF
@@ -687,6 +885,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_SNDBUF
#include <sys/types.h>
#include <sys/socket.h>
@@ -698,10 +897,16 @@
result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_SNDBUF,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_SNDBUF
+ #define
TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_SNDBUF(socketDescriptor,size,result)
\
+ CP_NETWORK_SOCKET_SET_OPTION_SO_SNDBUF(socketDescriptor,size,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
-* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_RCDBUF
-* Purpose : set socket option SO_RCDBUF
+* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_RCVBUF
+* Purpose : set socket option SO_RCVBUF
* Input : socketDescriptor - socket descriptor
* size - size of receive buffer
* Output : result - TARGET_NATIVE_OK if no error occurred,
@@ -711,10 +916,11 @@
* Notes : -
\***********************************************************************/
-#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_RCDBUF
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_RCVBUF
#include <sys/types.h>
#include <sys/socket.h>
- #define
TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_RCDBUF(socketDescriptor,size,result)
\
+ #define
TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_RCVBUF(socketDescriptor,size,result)
\
do { \
int __value; \
\
@@ -722,6 +928,12 @@
result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_RCVBUF,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_RCVBUF
+ #define
TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_RCVBUF(socketDescriptor,size,result)
\
+ CP_NETWORK_SOCKET_SET_OPTION_SO_RCVBUF(socketDescriptor,size,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_IP_TTL
@@ -735,6 +947,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_IP_TTL
#include <sys/types.h>
#include <sys/socket.h>
@@ -747,6 +960,12 @@
result=(setsockopt(socketDescriptor,IPPROTO_IP,IP_TTL,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_IP_TTL
+ #define
TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_IP_TTL(socketDescriptor,value,result) \
+ CP_NETWORK_SOCKET_SET_OPTION_IP_TTL(socketDescriptor,value,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_IP_MULTICAST_IF
@@ -760,6 +979,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_IP_MULTICAST_IF
#include <sys/types.h>
#include <sys/socket.h>
@@ -774,6 +994,12 @@
result=(setsockopt(socketDescriptor,IPPROTO_IP,IP_MULTICAST_IF,&__socketAddress,sizeof(__socketAddress))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_IP_MULTICAST_IF
+ #define
TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_IP_MULTICAST_IF(socketDescriptor,address,result)
\
+
CP_NETWORK_SOCKET_SET_OPTION_IP_MULTICAST_IF(socketDescriptor,address,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_REUSE_ADDRESS
@@ -787,6 +1013,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_REUSE_ADDRESS
#include <sys/types.h>
#include <sys/socket.h>
@@ -799,6 +1026,12 @@
result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_REUSEADDR,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_REUSE_ADDRESS
+ #define
TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_REUSE_ADDRESS(socketDescriptor,flag,result)
\
+ CP_NETWORK_SOCKET_SET_OPTION_REUSE_ADDRESS(socketDescriptor,flag,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_ADD_MEMBERSHIP
@@ -812,6 +1045,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_ADD_MEMBERSHIP
#include <sys/types.h>
#include <sys/socket.h>
@@ -826,6 +1060,12 @@
result=(setsockopt(socketDescriptor,IPPROTO_IP,IP_ADD_MEMBERSHIP,&__request,sizeof(__request))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_ADD_MEMBERSHIP
+ #define
TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_ADD_MEMBERSHIP(socketDescriptor,address,result)
\
+
CP_NETWORK_SOCKET_SET_OPTION_ADD_MEMBERSHIP(socketDescriptor,address,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_DROP_MEMBERSHIP
@@ -839,6 +1079,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_DROP_MEMBERSHIP
#include <sys/types.h>
#include <sys/socket.h>
@@ -853,6 +1094,12 @@
result=(setsockopt(socketDescriptor,IPPROTO_IP,IP_DROP_MEMBERSHIP,&__request,sizeof(__request))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_DROP_MEMBERSHIP
+ #define
TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_DROP_MEMBERSHIP(socketDescriptor,address,result)
\
+
CP_NETWORK_SOCKET_SET_OPTION_DROP_MEMBERSHIP(socketDescriptor,address,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_KEEP_ALIVE
@@ -866,6 +1113,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_KEEP_ALIVE
#include <sys/types.h>
#include <sys/socket.h>
@@ -878,6 +1126,12 @@
result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_KEEPALIVE,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_KEEP_ALIVE
+ #define
TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_KEEP_ALIVE(socketDescriptor,flag,result)
\
+ CP_NETWORK_SOCKET_SET_OPTION_KEEP_ALIVE(socketDescriptor,flag,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_BROADCAST
@@ -891,6 +1145,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_BROADCAST
#include <sys/types.h>
#include <sys/socket.h>
@@ -903,6 +1158,12 @@
result=(setsockopt(socketDescriptor,SOL_SOCKET,SO_BROADCAST,&__value,sizeof(__value))==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_BROADCAST
+ #define
TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_BROADCAST(socketDescriptor,flag,result)
\
+ CP_NETWORK_SOCKET_SET_OPTION_BROADCAST(socketDescriptor,flag,result)
+#endif
+#endif /* NEW_CP */
/*---------------------------------------------------------------------*/
@@ -918,6 +1179,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_TCP_NODELAY
#include <sys/types.h>
#include <sys/socket.h>
@@ -933,10 +1195,18 @@
result=(getsockopt(socketDescriptor,IPPROTO_TCP,TCP_NODELAY,&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
if (result==TARGET_NATIVE_OK) \
{ \
+ /* make sure all data in __value has been written to avoid undefined
values */ \
+ assert(__len>=sizeof(__value)); \
flag=__value; \
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_TCP_NODELAY
+ #define
TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_TCP_NODELAY(socketDescriptor,flag,result)
\
+ CP_NETWORK_SOCKET_GET_OPTION_TCP_NODELAY(socketDescriptor,flag,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_LINGER
@@ -951,6 +1221,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_LINGER
#include <sys/types.h>
#include <sys/socket.h>
@@ -966,11 +1237,19 @@
result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_LINGER,&__linger,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
if (result==TARGET_NATIVE_OK) \
{ \
+ /* make sure all data in __value has been written to avoid undefined
values */ \
+ assert(__len>=sizeof(__linger)); \
flag =__linger.l_onoff; \
value=__linger.l_linger; \
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_LINGER
+ #define
TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_LINGER(socketDescriptor,flag,value,result)
\
+ CP_NETWORK_SOCKET_GET_OPTION_SO_LINGER(socketDescriptor,flag,value,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_TIMEOUT
@@ -984,6 +1263,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_TIMEOUT
#include <sys/types.h>
#include <sys/socket.h>
@@ -998,10 +1278,18 @@
result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_TIMEOUT,&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
if (result==TARGET_NATIVE_OK) \
{ \
+ /* make sure all data in __value has been written to avoid undefined
values */ \
+ assert(__len>=sizeof(__value)); \
flag=__value; \
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_TIMEOUT
+ #define
TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_TIMEOUT(socketDescriptor,flag,result)
\
+ CP_NETWORK_SOCKET_GET_OPTION_SO_TIMEOUT(socketDescriptor,flag,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_SNDBUF
@@ -1015,6 +1303,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_SNDBUF
#include <sys/types.h>
#include <sys/socket.h>
@@ -1029,14 +1318,22 @@
result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_SNDBUF,&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
if (result==TARGET_NATIVE_OK) \
{ \
+ /* make sure all data in __value has been written to avoid undefined
values */ \
+ assert(__len>=sizeof(__value)); \
size=__value; \
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_SNDBUF
+ #define
TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_SNDBUF(socketDescriptor,size,result)
\
+ CP_NETWORK_SOCKET_GET_OPTION_SO_SNDBUF(socketDescriptor,size,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
-* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_RCDBUF
-* Purpose : get socket option SO_RCDBUF
+* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_RCVBUF
+* Purpose : get socket option SO_RCVBUF
* Input : socketDescriptor - socket descriptor
* Output : size - size of receive buffer
* result - TARGET_NATIVE_OK if no error occurred,
@@ -1046,10 +1343,11 @@
* Notes : -
\***********************************************************************/
-#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_RCDBUF
+#ifndef NEW_CP
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_RCVBUF
#include <sys/types.h>
#include <sys/socket.h>
- #define
TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_RCDBUF(socketDescriptor,size,result)
\
+ #define
TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_RCVBUF(socketDescriptor,size,result)
\
do { \
int __value; \
socklen_t __len; \
@@ -1060,10 +1358,18 @@
result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_RCVBUF,&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
if (result==TARGET_NATIVE_OK) \
{ \
+ /* make sure all data in __value has been written to avoid undefined
values */ \
+ assert(__len>=sizeof(__value)); \
size=__value; \
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_RCVBUF
+ #define
TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_SO_RCVBUF(socketDescriptor,size,result)
\
+ CP_NETWORK_SOCKET_GET_OPTION_SO_RCVBUF(socketDescriptor,size,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_IP_TTL
@@ -1077,6 +1383,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_IP_TTL
#include <sys/types.h>
#include <sys/socket.h>
@@ -1092,10 +1399,18 @@
result=(getsockopt(socketDescriptor,IPPROTO_IP,IP_TTL,&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
if (result==TARGET_NATIVE_OK) \
{ \
+ /* make sure all data in __value has been written to avoid undefined
values */ \
+ assert(__len>=sizeof(__value)); \
flag=__value; \
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_IP_TTL
+ #define
TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_IP_TTL(socketDescriptor,flag,result) \
+ CP_NETWORK_SOCKET_GET_OPTION_IP_TTL(socketDescriptor,flag,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_IP_MULTICAST_IF
@@ -1109,6 +1424,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_IP_MULTICAST_IF
#include <sys/types.h>
#include <sys/socket.h>
@@ -1127,10 +1443,18 @@
result=(getsockopt(socketDescriptor,IPPROTO_IP,IP_MULTICAST_IF,&__socketAddress,&__socketAddressLength)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
if (result==TARGET_NATIVE_OK) \
{ \
+ /* make sure all data in __socketAddress has been written to avoid
undefined values */ \
+ assert(__socketAddressLength>=sizeof(__socketAddress)); \
address=ntohl(__socketAddress.sin_addr.s_addr); \
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_IP_MULTICAST_IF
+ #define
TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_IP_MULTICAST_IF(socketDescriptor,address,result)
\
+
CP_NETWORK_SOCKET_GET_OPTION_IP_MULTICAST_IF(socketDescriptor,address,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_BIND_ADDRESS
@@ -1144,6 +1468,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_BIND_ADDRESS
#include <sys/types.h>
#include <sys/socket.h>
@@ -1160,10 +1485,18 @@
result=(getsockname(socketDescriptor,(struct
sockaddr*)&__socketAddress,&__socketAddressLength)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
if (result==TARGET_NATIVE_OK) \
{ \
+ /* make sure all data in __socketAddress has been written to avoid
undefined values */ \
+ assert(__socketAddressLength>=sizeof(__socketAddress)); \
address=ntohl(__socketAddress.sin_addr.s_addr); \
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_BIND_ADDRESS
+ #define
TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_BIND_ADDRESS(socketDescriptor,address,result)
\
+ CP_NETWORK_SOCKET_GET_OPTION_BIND_ADDRESS(socketDescriptor,address,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_REUSE_ADDRESS
@@ -1177,6 +1510,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_REUSE_ADDRESS
#include <sys/types.h>
#include <sys/socket.h>
@@ -1192,10 +1526,18 @@
result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_REUSEADDR,&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
if (result==TARGET_NATIVE_OK) \
{ \
+ /* make sure all data in __value has been written to avoid undefined
values */ \
+ assert(__len>=sizeof(__value)); \
flag=__value; \
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_REUSE_ADDRESS
+ #define
TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_REUSE_ADDRESS(socketDescriptor,flag,result)
\
+ CP_NETWORK_SOCKET_GET_OPTION_REUSE_ADDRESS(socketDescriptor,flag,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_KEEP_ALIVE
@@ -1209,6 +1551,7 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_KEEP_ALIVE
#include <sys/types.h>
#include <sys/socket.h>
@@ -1224,10 +1567,18 @@
result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_KEEPALIVE,&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
if (result==TARGET_NATIVE_OK) \
{ \
+ /* make sure all data in __value has been written to avoid undefined
values */ \
+ assert(__len>=sizeof(__value)); \
flag=__value; \
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_KEEP_ALIVE
+ #define
TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_KEEP_ALIVE(socketDescriptor,flag,result)
\
+ CP_NETWORK_SOCKET_GET_OPTION_KEEP_ALIVE(socketDescriptor,flag,result)
+#endif
+#endif /* NEW_CP */
/***********************************************************************\
* Name : TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_BROADCAST
@@ -1241,13 +1592,14 @@
* Notes : -
\***********************************************************************/
+#ifndef NEW_CP
#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; \
+ int __value; \
socklen_t __len; \
\
flag=0; \
@@ -1256,10 +1608,18 @@
result=(getsockopt(socketDescriptor,SOL_SOCKET,SO_BROADCAST,&__value,&__len)==0)?TARGET_NATIVE_OK:TARGET_NATIVE_ERROR;
\
if (result==TARGET_NATIVE_OK) \
{ \
+ /* make sure all data in __value has been written to avoid undefined
values */ \
+ assert(__len>=sizeof(__value)); \
flag=__value; \
} \
} while (0)
#endif
+#else /* NEW_CP */
+#ifndef TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_BROADCAST
+ #define
TARGET_NATIVE_NETWORK_SOCKET_GET_OPTION_BROADCAST(socketDescriptor,flag,result)
\
+ CP_NETWORK_SOCKET_GET_OPTION_BROADCAST(socketDescriptor,flag,result)
+#endif
+#endif /* NEW_CP */
/***************************** Functions *******************************/
@@ -1275,3 +1635,4 @@
/* end of file */
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] Patching of native/target,
Torsten Rupp <=