summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtchang%redhat.com <devnull@localhost>2005-01-17 22:13:36 +0000
committerwtchang%redhat.com <devnull@localhost>2005-01-17 22:13:36 +0000
commitb096e38c7cb3a506b922329e04d168269e415bd2 (patch)
tree13d3672ccea25e09f4d9f3090c890f6c07d421de
parent79ef7fe5c7837d00727e5aef64ac857c08af4d52 (diff)
downloadnspr-hg-b096e38c7cb3a506b922329e04d168269e415bd2.tar.gz
Bugzilla bug 276330: add a new configuration macro _PR_HAVE_O_APPEND,
which should be defined on platforms (e.g., Unix and BeOS) that have O_APPEND or its equivalent. The patch is contributed by tqh <thesuckiestemail@yahoo.se>. r=wtc,sergei_d. Modified files: _beos.h _unixos.h primpl.h prfile.c Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
-rw-r--r--pr/include/md/_beos.h1
-rw-r--r--pr/include/md/_unixos.h2
-rw-r--r--pr/include/private/primpl.h7
-rw-r--r--pr/src/io/prfile.c16
4 files changed, 16 insertions, 10 deletions
diff --git a/pr/include/md/_beos.h b/pr/include/md/_beos.h
index 40fa86d7..38dd5fb8 100644
--- a/pr/include/md/_beos.h
+++ b/pr/include/md/_beos.h
@@ -95,6 +95,7 @@
#define _PR_PEEK_BUFFER_MAX (16 * 1024)
#define _PR_FD_NEED_EMULATE_MSG_PEEK(fd) 1
#define _PR_CONNECT_DOES_NOT_BIND
+#define _PR_HAVE_O_APPEND
/* Define threading functions and objects as native BeOS */
struct _MDThread {
diff --git a/pr/include/md/_unixos.h b/pr/include/md/_unixos.h
index a8e87b4d..dd3e948a 100644
--- a/pr/include/md/_unixos.h
+++ b/pr/include/md/_unixos.h
@@ -79,6 +79,8 @@
#include <sys/select.h>
#endif
+#define _PR_HAVE_O_APPEND
+
#define PR_DIRECTORY_SEPARATOR '/'
#define PR_DIRECTORY_SEPARATOR_STR "/"
#define PR_PATH_SEPARATOR ':'
diff --git a/pr/include/private/primpl.h b/pr/include/private/primpl.h
index cb80a53b..07d4a3ed 100644
--- a/pr/include/private/primpl.h
+++ b/pr/include/private/primpl.h
@@ -1738,8 +1738,11 @@ struct PRFilePrivate {
PRInt32 peekBufSize;
PRInt32 peekBytes;
#endif
-#if !defined(XP_UNIX) /* BugZilla: 4090 */
- PRBool appendMode;
+#if !defined(_PR_HAVE_O_APPEND)
+ PRBool appendMode; /* Some platforms don't have O_APPEND or its
+ * equivalent, so they have to seek to end of
+ * file on write if the file was opened in
+ * append mode. See Bugzilla 4090, 276330. */
#endif
_MDFileDesc md;
#ifdef _PR_STRICT_ADDR_LEN
diff --git a/pr/src/io/prfile.c b/pr/src/io/prfile.c
index 4d228e50..d91bffa2 100644
--- a/pr/src/io/prfile.c
+++ b/pr/src/io/prfile.c
@@ -98,14 +98,14 @@ static PRInt32 PR_CALLBACK FileWrite(PRFileDesc *fd, const void *buf, PRInt32 am
return rv;
count = 0;
-#if !defined(XP_UNIX) /* BugZilla: 4090 */
+#if !defined(_PR_HAVE_O_APPEND) /* Bugzilla: 4090, 276330 */
if ( PR_TRUE == fd->secret->appendMode ) {
rv = PR_Seek(fd, 0, PR_SEEK_END );
if ( -1 == rv ) {
return rv;
}
} /* if (fd->secret->appendMode...) */
-#endif /* XP_UNIX */
+#endif /* _PR_HAVE_O_APPEND */
while (amount > 0) {
temp = _PR_MD_WRITE(fd, buf, amount);
if (temp < 0) {
@@ -361,7 +361,7 @@ PR_IMPLEMENT(PRFileDesc*) PR_Open(const char *name, PRIntn flags, PRIntn mode)
{
PRInt32 osfd;
PRFileDesc *fd = 0;
-#if !defined(XP_UNIX) /* BugZilla: 4090 */
+#if !defined(_PR_HAVE_O_APPEND)
PRBool appendMode = ( PR_APPEND & flags )? PR_TRUE : PR_FALSE;
#endif
@@ -375,7 +375,7 @@ PR_IMPLEMENT(PRFileDesc*) PR_Open(const char *name, PRIntn flags, PRIntn mode)
if (!fd) {
(void) _PR_MD_CLOSE_FILE(osfd);
} else {
-#if !defined(XP_UNIX) /* BugZilla: 4090 */
+#if !defined(_PR_HAVE_O_APPEND)
fd->secret->appendMode = appendMode;
#endif
_PR_MD_INIT_FD_INHERITABLE(fd, PR_FALSE);
@@ -389,7 +389,7 @@ PR_IMPLEMENT(PRFileDesc*) PR_OpenFile(
{
PRInt32 osfd;
PRFileDesc *fd = 0;
-#if !defined(XP_UNIX) /* BugZilla: 4090 */
+#if !defined(_PR_HAVE_O_APPEND)
PRBool appendMode = ( PR_APPEND & flags )? PR_TRUE : PR_FALSE;
#endif
@@ -403,7 +403,7 @@ PR_IMPLEMENT(PRFileDesc*) PR_OpenFile(
if (!fd) {
(void) _PR_MD_CLOSE_FILE(osfd);
} else {
-#if !defined(XP_UNIX) /* BugZilla: 4090 */
+#if !defined(_PR_HAVE_O_APPEND)
fd->secret->appendMode = appendMode;
#endif
_PR_MD_INIT_FD_INHERITABLE(fd, PR_FALSE);
@@ -804,7 +804,7 @@ PR_IMPLEMENT(PRFileDesc*) PR_OpenFileUTF16(
{
PRInt32 osfd;
PRFileDesc *fd = 0;
-#if !defined(XP_UNIX) /* BugZilla: 4090 */
+#if !defined(_PR_HAVE_O_APPEND)
PRBool appendMode = ( PR_APPEND & flags )? PR_TRUE : PR_FALSE;
#endif
@@ -817,7 +817,7 @@ PR_IMPLEMENT(PRFileDesc*) PR_OpenFileUTF16(
if (!fd) {
(void) _PR_MD_CLOSE_FILE(osfd);
} else {
-#if !defined(XP_UNIX) /* BugZilla: 4090 */
+#if !defined(_PR_HAVE_O_APPEND)
fd->secret->appendMode = appendMode;
#endif
_PR_MD_INIT_FD_INHERITABLE(fd, PR_FALSE);