79 |
#include "java_io_FileDescriptor.h" |
#include "java_io_FileDescriptor.h" |
80 |
|
|
81 |
// FIXME: This can't be right. Need converter macros |
// FIXME: This can't be right. Need converter macros |
82 |
#define CONVERT_JLONG_TO_INT(x) ((int)(x & 0xFFFF)) |
#define CONVERT_JLONG_TO_INT(x) ((int)(x & 0xFFFFFFFF)) |
83 |
|
|
84 |
// FIXME: This can't be right. Need converter macros |
// FIXME: This can't be right. Need converter macros |
85 |
#define CONVERT_JLONG_TO_OFF_T(x) (x) |
#define CONVERT_JLONG_TO_OFF_T(x) (x) |
86 |
|
|
87 |
// FIXME: This can't be right. Need converter macros |
// FIXME: This can't be right. Need converter macros |
88 |
#define CONVERT_JINT_TO_INT(x) ((int)(x & 0xFFFF)) |
#define CONVERT_JINT_TO_INT(x) ((int)(x & 0xFFFFFFFF)) |
89 |
|
|
90 |
|
// FIXME: This can't be right. Need converter macros |
91 |
|
#define CONVERT_SSIZE_T_TO_JINT(x) ((jint)(x & 0xFFFFFFFF)) |
92 |
|
|
93 |
/* These values must be kept in sync with FileDescriptor.java. */ |
/* These values must be kept in sync with FileDescriptor.java. */ |
94 |
#define SET 0 |
#define SET 0 |
345 |
if (bytes_read == 0) |
if (bytes_read == 0) |
346 |
return(-1); /* Signal end of file to Java */ |
return(-1); /* Signal end of file to Java */ |
347 |
else |
else |
348 |
return((jint)(bytes_read & 0xFFFF)); |
return(CONVERT_SSIZE_T_TO_JINT(bytes_read)); |
349 |
} |
} |
350 |
|
|
351 |
if ((rc == -1) && (errno != EINTR)) |
if ((rc == -1) && (errno != EINTR)) |
358 |
} |
} |
359 |
|
|
360 |
(*env)->ReleaseByteArrayElements(env, buf, bufptr, 0); |
(*env)->ReleaseByteArrayElements(env, buf, bufptr, 0); |
361 |
return((jint)(bytes_read & 0xFFFF)); |
return(CONVERT_SSIZE_T_TO_JINT(bytes_read)); |
362 |
} |
} |
363 |
|
|
364 |
/*************************************************************************/ |
/*************************************************************************/ |
433 |
if (!found) |
if (!found) |
434 |
return(0); |
return(0); |
435 |
else |
else |
436 |
return((jint)(num & 0xFFFF)); |
return(CONVERT_SSIZE_T_TO_JINT(num)); |
437 |
|
|
438 |
#else /* defined FIONREAD, HAVE_SELECT, HAVE_FSTAT */ |
#else /* defined FIONREAD, HAVE_SELECT, HAVE_FSTAT */ |
439 |
/* FIXME: Probably operation isn't supported, but this exception |
/* FIXME: Probably operation isn't supported, but this exception |