summaryrefslogtreecommitdiff
path: root/libio/oldiofdopen.c
diff options
context:
space:
mode:
Diffstat (limited to 'libio/oldiofdopen.c')
-rw-r--r--libio/oldiofdopen.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/libio/oldiofdopen.c b/libio/oldiofdopen.c
index 33406ff240..cec6642fc4 100644
--- a/libio/oldiofdopen.c
+++ b/libio/oldiofdopen.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -32,11 +32,7 @@
#include "libioP.h"
#include <fcntl.h>
-#ifndef _IO_fcntl
-# define _IO_fcntl __fcntl
-#endif
-
-_IO_FILE *
+FILE *
attribute_compat_text_section
_IO_old_fdopen (int fd, const char *mode)
{
@@ -64,16 +60,12 @@ _IO_old_fdopen (int fd, const char *mode)
read_write = _IO_NO_READS|_IO_IS_APPENDING;
break;
default:
- MAYBE_SET_EINVAL;
+ __set_errno (EINVAL);
return NULL;
}
if (mode[0] == '+' || (mode[0] == 'b' && mode[1] == '+'))
read_write &= _IO_IS_APPENDING;
-#ifdef F_GETFL
- fd_flags = _IO_fcntl (fd, F_GETFL);
-#ifndef O_ACCMODE
-#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
-#endif
+ fd_flags = __fcntl (fd, F_GETFL);
if (fd_flags == -1
|| ((fd_flags & O_ACCMODE) == O_RDONLY && !(read_write & _IO_NO_WRITES))
|| ((fd_flags & O_ACCMODE) == O_WRONLY && !(read_write & _IO_NO_READS)))
@@ -97,12 +89,9 @@ _IO_old_fdopen (int fd, const char *mode)
*/
if ((posix_mode & O_APPEND) && !(fd_flags & O_APPEND))
{
-#ifdef F_SETFL
- if (_IO_fcntl (fd, F_SETFL, fd_flags | O_APPEND) == -1)
-#endif
+ if (__fcntl (fd, F_SETFL, fd_flags | O_APPEND) == -1)
return NULL;
}
-#endif
new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE));
if (new_f == NULL)
@@ -112,10 +101,7 @@ _IO_old_fdopen (int fd, const char *mode)
#endif
_IO_old_init (&new_f->fp.file._file, 0);
_IO_JUMPS_FILE_plus (&new_f->fp) = &_IO_old_file_jumps;
- _IO_old_file_init ((struct _IO_FILE_plus *) &new_f->fp);
-#if !_IO_UNIFIED_JUMPTABLES
- new_f->fp.vtable = NULL;
-#endif
+ _IO_old_file_init_internal ((struct _IO_FILE_plus *) &new_f->fp);
if (_IO_old_file_attach (&new_f->fp.file._file, fd) == NULL)
{
_IO_un_link ((struct _IO_FILE_plus *) &new_f->fp);
@@ -127,7 +113,7 @@ _IO_old_fdopen (int fd, const char *mode)
_IO_mask_flags (&new_f->fp.file._file, read_write,
_IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING);
- return (_IO_FILE *) &new_f->fp;
+ return (FILE *) &new_f->fp;
}
strong_alias (_IO_old_fdopen, __old_fdopen)