+1998-07-31 17:59 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/generic/bits/byteswap.h: Fix problems with side effects.
+
+ * manual/filesys.texi: Document truncate and ftruncate.
+ Patch by Michael Deutschmann <michael@talamasca.wkpowerlink.com>.
+
+ * shadow/putspent.c: Lock stream while generating the output.
+
+ * sunrpc/clnt_unix.c: Use ucred instead of cmsgcred again.
+ (__msgwrite): Rewrite accordingly.
+ * sunrpc/svc_unix.c: Likewise.
+ * sysdeps/unix/sysv/linux/Dist: Remove __recvmsg.S and __sendmsg.S.
+ * sysdeps/unix/sysv/linux/Makefile [$(subdir)==socket]
+ (sysdep_routines): Remove __sendmsg and __recvmsg.
+ * sysdeps/unix/sysv/linux/__recvmsg.S: Removed.
+ * sysdeps/unix/sysv/linux/__sendmsg.S: Removed.
+ * sysdeps/unix/sysv/linux/recvmsg.c: Removed.
+ * sysdeps/unix/sysv/linux/sendmsg.c: Removed.
+ * sysdeps/unix/sysv/linux/recvmsg.S: New file.
+ * sysdeps/unix/sysv/linux/sendmsg.S: New file.
+ * sysdeps/unix/sysv/linux/bits/socket.h: Define SCM_CREDENTIALS and
+ struct ucred. Remove struct cmsgcred.
+ Patches by Thorsten Kukuk.
+
+1998-08-03 Andreas Jaeger <aj@arthur.rhein-neckar.de>
+
+ * inet/rcmd.c (__ivaliduser): Allow '#' as comment character.
+
+1998-08-08 14:42 Ulrich Drepper <drepper@cygnus.com>
+
+ * argp/argp-help.c: Prepare to be used outside glibc without gcc by
+ adding usual alloca cruft.
+ Reported by Eleftherios Gkioulekas <lf@amath.washington.edu>.
+
+1998-04-05 Jim Meyering <meyering@ascend.com>
+
+ * lib/regex.c (WIDE_CHAR_SUPPORT): Define.
+ This now depends on HAVE_BTOWC so systems that lack btowc (like
+ solaris-2.5.1) don't lose.
+
+1998-08-07 Mark Kettenis <kettenis@phys.uva.nl>
+
+ * sysdeps/generic/bits/sigaction.h: Remove definition of SA_DISABLE.
+ * sysdeps/generic/bits/sigstack.h: Define SS_DISABLE, SS_ONSTACK,
+ MINSIGSTKZ and SIGSTKSZ. Definitions match BSD.
+ * hurd/sigunwind.c (_hurdsig_longjmp_from_handler): Use SS_ONSTACK
+ instead of SA_ONSTACK.
+ * sysdeps/mach/hurd/sigaltstack.c (__sigaltstack): Renamed from
+ sigaltstack, and created a weak alias. Use SS_DISABLE and
+ SS_ONSTACK instead of SA_DISABLE and SA_ONSTACK.
+ * sysdeps/mach/hurd/sigstack.c (sigstack): Use SS_ONSTACK instead
+ of SA_ONSTACK. Call __sigaltstack instead of sigaltstack.
+ * sysdeps/mach/hurd/i386/sigreturn.c (__sigreturn): Use SS_ONSTACK
+ instead of SA_ONSTACK.
+ * sysdeps/mach/hurd/alpha/sigreturn.c (__sigreturn): Likewise.
+ * sysdeps/mach/hurd/mips/sigreturn.c (__sigreturn): Likewise.
+ * sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
+ Use SS_DISABLE instead of SA_DISABLE. Use SS_ONSTACK instead of
+ SA_ONSTACK where appropriate.
+ * sysdeps/mach/hurd/alpha/trampoline.c (_hurd_setup_sighandler):
+ Likewise.
+ * sysdeps/mach/hurd/hppa/trampoline.c (_hurd_setup_sighandler):
+ Likewise.
+ * sysdeps/mach/hurd/mips/trampoline.c (_hurd_setup_sighandler):
+ Likewise.
+ * manual/signal.texi (Signal Stack): Talk about SS_DISABLE and
+ SS_ONSTACK instead of SA_DISABLE and SA_ONSTACK in discussion of
+ the `ss_flags' member of `struct sigaltstack'.
+
+1998-08-05 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * libio/Makefile (routines) [$(versioning)=yes]: Add oldtmpfile.
+ (shared-only-routines): Likewise.
+ * libio/oldtmpfile.c: New file
+ * stdio-common/tmpfile.c: Use __fdopen and __close.
+ [USE_IN_LIBIO]: Use _IO_fdopen instead of _IO_new_fdopen. Put
+ tmpfile on symbol version GLIBC_2.1.
+ * stdio-common/tmpfile64.c: Use __fdopen and __close.
+ [USE_IN_LIBIO]: Use _IO_fdopen instead of _IO_new_fdopen.
+ * stdio-common/Version [GLIBC_2.1]: Add tmpfile.
+ * stdio-common/tempnam.c: Use __strdup instead of strdup.
+ * sysdeps/posix/fdopen.c: Define __fdopen and make fdopen weak
+ alias.
+ * sysdeps/generic/fdopen.c: Likewise.
+ * sysdeps/mach/hurd/fdopen.c: Likewise.
+ * stdio/stdio.h: Declare __fdopen.
+ * sunrpc/openchild.c: Use __fdopen instead of fdopen.
+ [USE_IN_LIBIO]: Map __fdopen to _IO_fdopen.
+ * sysdeps/posix/tempname.c (__gen_tempname): Don't bother checking
+ __stub_open64, it is never defined.
+
+1998-08-05 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * libio/iofopen64.c: Fix typo. Avoid unnessary casts.
+ * libio/iopopen.c: Unlink file before freeing it if command
+ creation failed. Avoid unnessary casts.
+ * libio/iofdopen.c: Avoid unnecessary cast.
+ * pwd/fgetpwent_r.c [USE_IN_LIBIO]: Map funlockfile to
+ _IO_funlockfile.
+ * pwd/fgetspent_r.c [USE_IN_LIBIO]: Likewise.
+
+1998-08-06 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * grp/grp.h, pwd/pwd.h: Don't declare __grpopen, __grpread,
+ __grpalloc, __grpscan and the corresponding pwd functions, they
+ were removed long ago.
+
+1998-08-06 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * math/libm-test.c (csqrt_test): Adjust epsilons.
+ (casinh_test): Likewise.
+
+1998-08-06 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * posix/globtest.sh: Fix typo. Remove second test output file.
+
+1998-08-07 Cristian Gafton <gafton@redhat.com>
+
+ * pwd/putpwent.c (putpwent): Avoid writting (none) in the passwd file.
+ * shadow/putspent.c (putspent): Likewise.
+ * grp/putgrent.c: New file.
+ * grp/Makefile (routines): Add putgrent.
+ * grp/Versions [GLIBC_2.1]: Add putgrent.
+ * grp/grp.h: Add putgrent prototype.
+
+1998-08-04 19:33 Ulrich Drepper <drepper@cygnus.com>
+
+ * elf/elf.h: More ELF definitions.
+
1998-08-04 16:53 Ulrich Drepper <drepper@cygnus.com>
* stdio-common/tmpfile.c: Include unistd.h for close prototype.
#include <config.h>
#endif
+#ifndef alloca
+# ifdef __GNUC__
+# define alloca __builtin_alloca
+# define HAVE_ALLOCA 1
+# else
+# if defined HAVE_ALLOCA_H || defined _LIBC
+# include <alloca.h>
+# else
+# ifdef _AIX
+ #pragma alloca
+# else
+# ifndef alloca
+char *alloca ();
+# endif
+# endif
+# endif
+# endif
+#endif
+
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
/* Macros to swap the order of bytes in integer values.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998 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
#endif
/* Swap bytes in 16 bit value. */
-#define __bswap_16(x) \
- ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
+#ifdef __GNUC__
+# define __bswap_16(x) \
+ (__extension__ \
+ ({ unsigned short int __bsx = (x); \
+ ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8)); }))
+#else
+static __inline unsigned short int
+__bswap16 (unsigned short int x)
+{
+ return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8));
+}
+#endif
/* Swap bytes in 32 bit value. */
-#define __bswap_32(x) \
- ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
- (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
+#ifdef __GNUC__
+# define __bswap_32(x) \
+ (__extension__ \
+ ({ unsigned int __bsx = (x); \
+ ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) | \
+ (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24)); }))
+#else
+static __inline unsigned int
+__bswap32 (unsigned int x)
+{
+ return ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) |
+ (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24));
+}
+#endif
#if defined __GNUC__ && __GNUC__ >= 2
/* Swap bytes in 64 bit value. */
-/* Copyright (C) 1991, 1992, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1996, 1997, 1998 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
};
/* Bits in `sa_flags'. */
-#ifdef __USE_BSD
-# define SA_ONSTACK 0x1 /* Take signal on signal stack. */
-# define SA_RESTART 0x2 /* Restart syscall on signal return. */
-# define SA_DISABLE 0x4 /* Disable alternate signal stack. */
+#if defined __USE_UNIX98 || defined __USE_MISC
+# define SA_ONSTACK 0x0001 /* Take signal on signal stack. */
+# define SA_RESTART 0x0002 /* Restart syscall on signal return. */
#endif
-#define SA_NOCLDSTOP 0x8 /* Don't send SIGCHLD when children stop. */
+#define SA_NOCLDSTOP 0x0008 /* Don't send SIGCHLD when children stop. */
/* Values for the HOW argument to `sigprocmask'. */
size_t ss_size;
int ss_flags;
} stack_t;
+
+
+/* Possible values for `ss_flags.'. */
+enum
+{
+ SS_ONSTACK = 0x0001,
+#define SS_ONSTACK SS_ONSTACK
+ SS_DISABLE = 0x0004,
+#define SS_DISABLE SS_DISABLE
+};
+
+/* Minumum stack size for a signal handler. */
+#define MINSIGSTKSZ 8192
+
+/* System default stack size. */
+#define SIGSTKSZ (MINSIGSTKSZ + 32768)
#define EM_OLD_ALPHA 41 /* Digital Alpha */
#define EM_SH 42 /* Hitachi SH */
#define EM_SPARCV9 43 /* SPARC v9 64-bit */
-#define EM_NUM 44
+#define EM_TRICORE 44 /* Siemens Tricore */
+#define EM_ARC 45 /* Argonaut RISC Core */
+#define EM_H8_300 46 /* Hitachi H8/300 */
+#define EM_H8_300H 47 /* Hitachi H8/300H */
+#define EM_H8S 48 /* Hitachi H8S */
+#define EM_H8_500 49 /* Hitachi H8/500 */
+#define EM_IA_64 50 /* Intel Merced */
+#define EM_MIPS_X 51 /* Stanford MIPS-X */
+#define EM_COLDFIRE 52 /* Motorola Coldfire */
+#define EM_68HC12 53 /* Motorola M68HC12 */
+#define EM_NUM 54
/* If it is necessary to assign new unofficial EM_* values, please
pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
#define SHT_SHLIB 10 /* Reserved */
#define SHT_DYNSYM 11 /* Dynamic linker symbol table */
#define SHT_NUM 12 /* Number of defined types. */
+#define SHT_LOOS 0x60000000 /* Start OS-specific */
#define SHT_LOSUNW 0x6ffffffb /* Sun-specific low bound. */
#define SHT_SUNW_COMDAT 0x6ffffffb
#define SHT_SUNW_syminfo 0x6ffffffc
#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */
#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */
#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */
+#define SHT_HIOS 0x60000000 /* End OS-specific type */
#define SHT_LOPROC 0x70000000 /* Start of processor-specific */
#define SHT_HIPROC 0x7fffffff /* End of processor-specific */
#define SHT_LOUSER 0x80000000 /* Start of application-specific */
#define STB_GLOBAL 1 /* Global symbol */
#define STB_WEAK 2 /* Weak symbol */
#define STB_NUM 3 /* Number of defined types. */
+#define STB_LOOS 10 /* Start of OS-specific */
+#define STB_HIOS 12 /* End of OS-specific */
#define STB_LOPROC 13 /* Start of processor-specific */
#define STB_HIPROC 15 /* End of processor-specific */
#define STT_SECTION 3 /* Symbol associated with a section */
#define STT_FILE 4 /* Symbol's name is file name */
#define STT_NUM 5 /* Number of defined types. */
+#define STT_LOOS 11 /* Start of OS-specific */
+#define STT_HIOS 12 /* End of OS-specific */
#define STT_LOPROC 13 /* Start of processor-specific */
#define STT_HIPROC 15 /* End of processor-specific */
#define PT_SHLIB 5 /* Reserved */
#define PT_PHDR 6 /* Entry for header table itself */
#define PT_NUM 7 /* Number of defined types. */
+#define PT_LOOS 0x60000000 /* Start of OS-specific */
+#define PT_HIOS 0x6fffffff /* End of OS-specific */
#define PT_LOPROC 0x70000000 /* Start of processor-specific */
#define PT_HIPROC 0x7fffffff /* End of processor-specific */
#define DT_DEBUG 21 /* For debugging; unspecified */
#define DT_TEXTREL 22 /* Reloc might modify .text */
#define DT_JMPREL 23 /* Address of PLT relocs */
-#define DT_NUM 24 /* Number used */
+#define DT_BIND_NOW 24 /* Process relocations of object */
+#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */
+#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */
+#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */
+#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */
+#define DT_NUM 29 /* Number used */
+#define DT_LOOS 0x60000000 /* Start of OS-specific */
+#define DT_HIOS 0x6fffffff /* End of OS-specific */
#define DT_LOPROC 0x70000000 /* Start of processor-specific */
#define DT_HIPROC 0x7fffffff /* End of processor-specific */
#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */
#define R_68K_GLOB_DAT 20 /* Create GOT entry */
#define R_68K_JMP_SLOT 21 /* Create PLT entry */
#define R_68K_RELATIVE 22 /* Adjust by program base */
+/* Keep this the last entry. */
+#define R_68K_NUM 23
/* Intel 80386 specific definitions. */
#define R_386_RELATIVE 8 /* Adjust by program base */
#define R_386_GOTOFF 9 /* 32 bit offset to GOT */
#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */
+/* Keep this the last entry. */
+#define R_386_NUM 11
/* SUN SPARC specific definitions. */
#define R_SPARC_REGISTER 53 /* Global register usage */
#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */
#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */
+/* Keep this the last entry. */
+#define R_SPARC_NUM 56
/* For Sparc64, legal values for d_tag of Elf64_Dyn. */
#define R_MIPS_ADD_IMMEDIATE 34
#define R_MIPS_PJUMP 35
#define R_MIPS_RELGOT 36
+/* Keep this the last entry. */
+#define R_MIPS_NUM 37
/* Legal values for p_type field of Elf32_Phdr. */
#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */
#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */
#define R_ALPHA_RELATIVE 27 /* Adjust by program base */
+/* Keep this the last entry. */
+#define R_ALPHA_NUM 28
/* PowerPC specific declarations */
#define R_PPC_SECTOFF_LO 34
#define R_PPC_SECTOFF_HI 35
#define R_PPC_SECTOFF_HA 36
+/* Keep this the last entry. */
+#define R_PPC_NUM 37
/* The remaining relocs are from the Embedded ELF ABI, and are not
in the SVR4 ELF ABI. */
#define R_ARM_PC24 1 /* PC relative 26 bit branch */
#define R_ARM_ABS32 2 /* Direct 32 bit */
#define R_ARM_REL32 3 /* PC relative 32 bit */
+#define R_ARM_ABS8 4
+#define R_ARM_ABS16 5
+#define R_ARM_ABS12 6
+#define R_ARM_THM_ABS5 7
+#define R_ARM_THM_PC22 8
+#define R_ARM_SBREL32 9
+#define R_ARM_AMP_VCALL9 10
+#define R_ARM_THM_PC11 11
+#define R_ARM_THM_PC9 12
#define R_ARM_COPY 20 /* Copy symbol at runtime */
#define R_ARM_GLOB_DAT 21 /* Create GOT entry */
#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */
#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */
#define R_ARM_GOT32 26 /* 32 bit GOT entry */
#define R_ARM_PLT32 27 /* 32 bit PLT address */
+/* Keep this the last entry. */
+#define R_ARM_NUM 28
__END_DECLS
headers := grp.h
routines := fgetgrent initgroups setgroups \
- getgrent getgrgid getgrnam \
+ getgrent getgrgid getgrnam putgrent \
getgrent_r getgrgid_r getgrnam_r fgetgrent_r
tests := testgrp
# s*
setgrent; setgroups;
}
+ GLIBC_2.1 {
+ # p*
+ putgrent;
+ }
}
# include <stdio.h>
#endif
-#ifdef __USE_GNU
-/* Return a new stream open on the group file. */
-extern FILE *__grpopen __P ((void));
-
-/* Read a group entry from STREAM, filling in G.
- Return the `struct group' of G if successful, NULL on failure. */
-extern struct group *__grpread __P ((FILE *__stream, __ptr_t __g));
-
-/* Return a chunk of memory containing pre-initialized data for __grpread. */
-extern __ptr_t __grpalloc __P ((void));
-
-/* Scan the group file, filling in G, until SELECTOR returns nonzero for an
- entry. Return the `struct group' of G if successful, NULL on failure. */
-extern struct group *__grpscan __P ((__ptr_t *__p,
- int (*__selector) (struct group *)));
-#endif
-
#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
/* Rewind the group-file stream. */
extern struct group *fgetgrent __P ((FILE *__stream));
#endif
+#ifdef __USE_GNU
+/* Write the given entry onto the given stream. */
+extern int putgrent __P ((__const struct group *__p, FILE *__f));
+#endif
+
/* Search for an entry with a matching group ID. */
extern struct group *getgrgid __P ((__gid_t __gid));
--- /dev/null
+/* Copyright (C) 1991, 1992, 1996, 1998 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
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <stdio.h>
+#include <grp.h>
+
+#ifdef USE_IN_LIBIO
+# define flockfile(s) _IO_flockfile (s)
+# define funlockfile(s) _IO_funlockfile (s)
+#endif
+
+#define _S(x) x ? x : ""
+
+/* Write an entry to the given stream.
+ This must know the format of the group file. */
+int
+putgrent (gr, stream)
+ const struct group *gr;
+ FILE *stream;
+{
+ int retval;
+
+ if (gr == NULL || stream == NULL)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ flockfile (stream);
+
+ retval = fprintf (stream, "%s:%s:%u:",
+ gr->gr_name, _S (gr->gr_passwd), gr->gr_gid);
+ if (retval < 0)
+ return -1;
+
+ if (gr->gr_mem != NULL)
+ {
+ int i;
+
+ for (i = 0 ; gr->gr_mem[i] != NULL; i++)
+ if (fprintf (stream, "%c%s", i == 0 ? ':' : ',', gr->gr_mem[i]) < 0)
+ {
+ /* What else can we do? */
+ funlockfile (stream);
+ return -1;
+ }
+ }
+
+ retval = fputc_unlocked ('\n', stream);
+
+ funlockfile (stream);
+
+ return retval < 0 ? -1 : 0;
+}
/* longjmp cleanup function for unwinding past signal handlers.
- Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1998 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
which calls us inside a critical section. */
assert (__spin_lock_locked (&ss->critical_section_lock));
/* Are we on the alternate signal stack now? */
- onstack = (ss->sigaltstack.ss_flags & SA_ONSTACK);
+ onstack = (ss->sigaltstack.ss_flags & SS_ONSTACK);
__spin_unlock (&ss->lock);
if (onstack && ! scp->sc_onstack)
register char *user, *p;
int ch;
char *buf = NULL;
+ char *cp;
size_t bufsize = 0;
ssize_t nread;
while ((nread = __getline (&buf, &bufsize, hostf)) > 0) {
buf[bufsize - 1] = '\0'; /* Make sure it's terminated. */
+ /* Because the file format does not know any form of quoting we
+ can search forward for the next '#' character and if found
+ make it terminating the line. */
+ cp = strchr (buf, '#');
+ if (cp != NULL)
+ *cp = '\0';
p = buf;
while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') {
*p = isupper(*p) ? tolower(*p) : *p;
include ../Makeconfig
ifeq ($(versioning),yes)
-routines += oldiofopen oldiofdopen oldiofclose
+routines += oldiofopen oldiofdopen oldiofclose oldtmpfile
endif
CPPFLAGS-.o += -DIO_DEBUG
endif
shared-only-routines = oldiofopen oldiofdopen oldiofclose oldfileops \
- oldstdfiles
+ oldstdfiles oldtmpfile
distribute := iolibio.h libioP.h strfile.h Banner
_IO_mask_flags (&new_f->fp.file, read_write,
_IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING);
- return (_IO_FILE *) &new_f->fp;
+ return &new_f->fp.file;
}
#if defined PIC && DO_VERSIONING
_IO_JUMPS (&new_f->fp) = &_IO_file_jumps;
_IO_file_init (&new_f->fp.file);
#if !_IO_UNIFIED_JUMPTABLES
- new_f->fp.plus.vtable = NULL;
+ new_f->fp.vtable = NULL;
#endif
if (_IO_file_fopen (&new_f->fp.file, filename, mode, 1) != NULL)
- return (_IO_FILE *) &new_f->fp;
+ return &new_f->fp.file;
_IO_un_link (&new_f->fp.file);
free (new_f);
return NULL;
#ifdef _IO_MTSAFE_IO
new_f->fpx.file.file._lock = &new_f->lock;
#endif
- fp = (_IO_FILE*)&new_f->fpx;
+ fp = &new_f->fpx.file.file;
_IO_init (fp, 0);
_IO_JUMPS (fp) = &_IO_proc_jumps;
_IO_file_init (fp);
#if !_IO_UNIFIED_JUMPTABLES
- ((struct _IO_FILE_plus *) fp)->vtable = NULL;
+ new_f->fpx.file.vtable = NULL;
#endif
if (_IO_proc_open (fp, command, mode) != NULL)
return fp;
+ _IO_un_link (fp);
free (new_f);
return NULL;
}
--- /dev/null
+/* Copyright (C) 1991, 1993, 1996, 1997, 1998 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
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#define _IO_USE_OLD_IO_FILE
+#include <stdio.h>
+#include <unistd.h>
+#include <iolibio.h>
+
+/* This returns a new stream opened on a temporary file (generated
+ by tmpnam). The file is opened with mode "w+b" (binary read/write).
+ If we couldn't generate a unique filename or the file couldn't
+ be opened, NULL is returned. */
+FILE *
+__old_tmpfile (void)
+{
+ char buf[FILENAME_MAX];
+ int fd;
+ FILE *f;
+
+ if (__path_search (buf, FILENAME_MAX, NULL, "tmpf"))
+ return NULL;
+ fd = __gen_tempname (buf, 1, 0);
+ if (fd < 0)
+ return NULL;
+
+ /* Note that this relies on the Unix semantics that
+ a file is not really removed until it is closed. */
+ (void) remove (buf);
+
+ if ((f = _IO_old_fdopen (fd, "w+b")) == NULL)
+ close (fd);
+
+ return f;
+}
+
+symbol_version (__old_tmpfile, tmpfile, GLIBC_2.0);
* Testing File Access:: How to find out if your process can
access a file.
* File Times:: About the time attributes of a file.
+* File Size:: Manually changing the size of a file.
@end menu
@node Attribute Meanings
function.
@end deftypefun
+@node File Size
+@subsection File Size
+
+Normally file sizes are maintained automatically. A file begins with a
+size of @math{0} and is automatically extended when data is written
+past its end. It is also possible to empty a file completely in an
+@code{open} or @code{fopen} call.
+
+However, sometimes it is neccessary to @emph{reduce} the size of a file.
+This can be done with the @code{truncate} and @code{ftruncate} functions.
+They were introduced in BSD Unix. @code{ftruncate} was later added to
+POSIX.1.
+
+Some systems allow you to extend a file (creating holes) with these
+functions. This is useful when using memory-mapped I/O
+(@pxref{Memory-mapped I/O}), where files are not automatically extended.
+However it is not portable but must be implemented if @code{mmap} allows
+mapping of files (i.e., @code{_POSIX_MAPPED_FILES} is defined).
+
+Using these functions on anything other than a regular file gives
+@emph{undefined} results. On many systems, such a call will appear to
+succeed, without actually accomplishing anything.
+
+@deftypefun int truncate (const char *@var{filename}, off_t @var{length})
+
+The @code{truncate} function changes the size of @var{filename} to
+@var{length}. If @var{length} is shorter than the previous length, data at
+the end will be lost.
+
+If @var{length} is longer, holes will be added to the end. However, some
+systems do not support this feature and will leave the file unchanged.
+
+The return value is @math{0} for success, or @math{-1} for an error. In
+addition to the usual file name errors, the following errors may occur:
+
+@table @code
+
+@item EACCES
+The file is a directory or not writable.
+
+@item EINVAL
+@var{length} is negative.
+
+@item EFBIG
+The operation would extend the file beyond the limits of the operating system.
+
+@item EIO
+A hardware I/O error occured.
+
+@item EPERM
+The file is "append-only" or "immutable".
+
+@item EINTR
+The operation was interrupted by a signal.
+
+@end table
+
+@end deftypefun
+
+@deftypefun int ftruncate (int @var{fd}, off_t @var{length})
+
+This is like @code{truncate}, but it works on a file descriptor @var{fd}.
+
+@code{ftruncate} is especially useful in combination with @code{mmap}.
+Since the mapped region must have a fixed size one cannot enlarge the
+file by writing something beyond the last mapped page. Instead one has
+to enlarge the file itself and then remap the file with the new size.
+The example below shows how this works.
+
+The return value is @math{0} for success, or @math{-1} for an error. The
+following errors may occur:
+
+@table @code
+
+@item EBADF
+@var{fd} does not correspond to an open file.
+
+@item EACCES
+@var{fd} is a directory or not open for write.
+
+@item EINVAL
+@var{length} is negative.
+
+@item EFBIG
+The operation would extend the file beyond the limits of the operating system.
+@c or the open() call -- with the not-yet-discussed feature of opening
+@c files with extra-large offsets.
+
+@item EIO
+A hardware I/O error occured.
+
+@item EPERM
+The file is "append-only" or "immutable".
+
+@item EINTR
+The operation was interrupted by a signal.
+
+@c ENOENT is also possible on Linux --- however it only occurs if the file
+@c descriptor has a `file' structure but no `inode' structure. I'm not
+@c sure how such an fd could be created. Perhaps it's a bug.
+
+@end table
+
+@end deftypefun
+
+As announced here is a little example how to use @code{ftruncate} in
+combination with @code{mmap}:
+
+@smallexample
+int fd;
+void *start;
+size_t len;
+
+int
+add (off_t at, void *block, size_t size)
+@{
+ if (at + size > len)
+ @{
+ /* Resize the file and remap. */
+ size_t ps = sysconf (_SC_PAGESIZE);
+ size_t ns = (at + size + ps - 1) & ~(ps - 1);
+ void *np;
+ if (ftruncate (fd, ns) < 0)
+ return -1;
+ np = mmap (NULL, ns, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+ if (np == MAP_FAILED)
+ return -1;
+ start = np;
+ len = ns;
+ @}
+ memcpy ((char *) start + at, block, size);
+ return 0;
+@}
+@end smallexample
+
+The function @code{add} allows to add at arbitrary positions in the file
+given blocks of memory. If the current size of the file is too small it
+is extended. Please note the it is extended in multiples of a pagesize.
+This is a requirement of @code{mmap}. The program has to track the real
+size and once the program finished to work a final @code{ftruncate} call
+should set the real size of the file.
+
@node Making Special Files
@section Making Special Files
@cindex creating special files
This field contains the bitwise @sc{or} of these flags:
@vtable @code
-@item SA_DISABLE
+@item SS_DISABLE
This tells the system that it should not use the signal stack.
-@item SA_ONSTACK
+@item SS_ONSTACK
This is set by the system, and indicates that the signal stack is
currently in use. If this bit is not set, then signals will be
delivered on the normal user stack.
check_eps ("real(casinh(0.7 + i 1.2)) == 0.97865...", __real__ result,
0.9786545955936738768L, CHOOSE(5e-17L, 2e-16, 0));
check_eps ("imag(casinh(0.7 + i 1.2)) == 0.91135...", __imag__ result,
- 0.9113541895315601156L, CHOOSE(7e-19L, 2e-16, 6e-8));
+ 0.9113541895315601156L, CHOOSE(7e-19L, 2e-16, 2e-7));
result = FUNC(casinh) (BUILD_COMPLEX (-2, -3));
check_eps ("real(casinh(-2 - i 3)) == -1.96863...", __real__ result,
- -1.9686379257930962917L, CHOOSE(7e-19L, 2e-15, 2e-7));
+ -1.9686379257930962917L, CHOOSE(7e-19L, 2e-15, 3e-6));
check_eps ("imag(casinh(-2 - i 3)) == -0.96465...", __imag__ result,
-0.9646585044076027920L, CHOOSE(4e-19L, 2e-15, 4e-7));
}
result = FUNC(csqrt) (BUILD_COMPLEX (-2, -3));
check_eps ("real(csqrt(-2 - i 3)) == 0.89597...", __real__ result,
- 0.8959774761298381247L, CHOOSE(6e-20L, 2e-16, 6e-8));
+ 0.8959774761298381247L, CHOOSE(6e-16L, 4e-16, 6e-8));
check_eps ("imag(csqrt(-2 - i 3)) == -1.67414...", __imag__ result,
-1.6741492280355400404L, CHOOSE(0, 5e-16, 0));
result = FUNC(csqrt) (BUILD_COMPLEX (-2, 3));
check_eps ("real(csqrt(-2 + i 3)) == 0.89597...", __real__ result,
- 0.8959774761298381247L, CHOOSE(6e-20L, 2e-16, 6e-8));
+ 0.8959774761298381247L, CHOOSE(6e-20L, 4e-16, 6e-8));
check_eps ("imag(csqrt(-2 + i 3)) == 1.67414...", __imag__ result,
1.6741492280355400404L, CHOOSE(0, 5e-16, 0));
}
# We have to find the libc and the NSS modules.
library_path=${common_objpfx}:${common_objpfx}nss:${common_objpfx}nis
-# Since we use `osrt' we must make sure to use the same locale everywhere.
+# Since we use `sort' we must make sure to use the same locale everywhere.
LC_ALL=C
export LC_ALL
LANG=C
: ${TMPDIR=/tmp}
testdir=$TMPDIR/globtest-dir
testout=$TMPDIR/globtest-out
-testout2=$TMPDIR/globtest-out2
-trap 'rm -fr $testdir $testout $testout2' 1 2 3 15
+trap 'rm -fr $testdir $testout' 1 2 3 15
rm -fr $testdir
mkdir $testdir
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
${common_objpfx}posix/globtest -q -t "$testdir" "~" |
sort >$testout
-echo ~ > $testout2
-cmp $testout2 $testout || result=1
+echo ~ | cmp - $testout || result=1
# Test tilde expansion with trailing slash
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
${common_objpfx}posix/globtest -q -t "$testdir" "~/" |
sort > $testout
-echo ~/ > $testout2
-cmp $testout2 $testout || result=1
+echo ~/ | cmp - $testout || result=1
# Test tilde expansion with username
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
${common_objpfx}posix/globtest -q -t "$testdir" "~"$USER |
sort > $testout
-eval echo ~$USER > $testout2
-cmp $testout2 $testout || result=1
+eval echo ~$USER | cmp - $testout || result=1
# Tilde expansion shouldn't match a file
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
# include <sys/types.h>
#endif
+#define WIDE_CHAR_SUPPORT \
+ defined _LIBC || (HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_BTOWC)
+
/* For platform which support the ISO C amendement 1 functionality we
support user defined character classes. */
-#if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
+#if WIDE_CHAR_SUPPORT
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
# include <wchar.h>
# include <wctype.h>
} \
}
-#if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
+#if WIDE_CHAR_SUPPORT
/* The GNU C library provides support for user-defined character classes
and the functions from ISO C amendement 1. */
# ifdef CHARCLASS_NAME_MAX
the leading `:' and `[' (but set bits for them). */
if (c == ':' && *p == ']')
{
-#if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
+#if WIDE_CHAR_SUPPORT
boolean is_lower = STREQ (str, "lower");
boolean is_upper = STREQ (str, "upper");
wctype_t wt;
# ifdef _LIBC
if (__iswctype (__btowc (ch), wt))
SET_LIST_BIT (ch);
-#else
+# else
if (iswctype (btowc (ch), wt))
SET_LIST_BIT (ch);
-#endif
+# endif
if (translate && (is_upper || is_lower)
&& (ISUPPER (ch) || ISLOWER (ch)))
#ifdef USE_IN_LIBIO
# define flockfile(s) _IO_flockfile (s)
+# define funlockfile(s) _IO_funlockfile (s)
#endif
/* Define a line parsing function using the common code
-/* Copyright (C) 1991, 1992, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1996, 1997, 1998 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
#include <stdio.h>
#include <pwd.h>
+#define _S(x) x ? x : ""
/* Write an entry to the given stream.
This must know the format of the password file. */
}
if (fprintf (stream, "%s:%s:%u:%u:%s:%s:%s\n",
- p->pw_name, p->pw_passwd,
+ p->pw_name, _S (p->pw_passwd),
p->pw_uid, p->pw_gid,
- p->pw_gecos, p->pw_dir, p->pw_shell) < 0)
+ _S (p->pw_gecos), _S (p->pw_dir), _S (p->pw_shell)) < 0)
return -1;
return 0;
# include <stdio.h>
#endif
-#ifdef __USE_GNU
-/* Return a new stream open on the password file. */
-extern FILE *__pwdopen __P ((void));
-
-/* Read a password entry from STREAM, filling in P.
- Return the `struct passwd' of P if successful, NULL on failure. */
-extern struct passwd *__pwdread __P ((FILE *__stream, __ptr_t __p));
-
-/* Return a chunk of memory containing pre-initialized data for __pwdread. */
-extern __ptr_t __pwdalloc __P ((void));
-
-/* Scan the password file, filling in P, until SELECTOR returns nonzero for
- an entry. Return the `struct passwd' of P if successful, NULL on
- failure. */
-extern struct passwd *__pwdscan __P ((__ptr_t *__p,
- int (*__selector) (struct passwd *)));
-#endif
-
#if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN_EXTENDED
/* Rewind the password-file stream. */
#ifdef USE_IN_LIBIO
# define flockfile(s) _IO_flockfile (s)
+# define funlockfile(s) _IO_funlockfile (s)
#endif
/* Define a line parsing function using the common code
-/* Copyright (C) 1991, 1992, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1996, 1997, 1998 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
#include <stdio.h>
#include <shadow.h>
+#ifdef USE_IN_LIBIO
+# define flockfile(s) _IO_flockfile (s)
+# define funlockfile(s) _IO_funlockfile (s)
+#endif
+
+#define _S(x) x ? x : ""
+
/* Write an entry to the given stream.
This must know the format of the password file. */
{
int errors = 0;
- if (fprintf (stream, "%s:%s:", p->sp_namp, p->sp_pwdp) < 0)
+ flockfile (stream);
+
+ if (fprintf (stream, "%s:%s:", p->sp_namp, _S (p->sp_pwdp)) < 0)
++errors;
if ((p->sp_lstchg != (long int) -1
&& fprintf (stream, "%ld:", p->sp_lstchg) < 0)
|| (p->sp_lstchg == (long int) -1
- && putc (':', stream) == EOF))
+ && putc_unlocked (':', stream) == EOF))
++errors;
if ((p->sp_min != (long int) -1
&& fprintf (stream, "%ld:", p->sp_min) < 0)
|| (p->sp_min == (long int) -1
- && putc (':', stream) == EOF))
+ && putc_unlocked (':', stream) == EOF))
++errors;
if ((p->sp_max != (long int) -1
&& fprintf (stream, "%ld:", p->sp_max) < 0)
|| (p->sp_max == (long int) -1
- && putc (':', stream) == EOF))
+ && putc_unlocked (':', stream) == EOF))
++errors;
if ((p->sp_warn != (long int) -1
&& fprintf (stream, "%ld:", p->sp_warn) < 0)
|| (p->sp_warn == (long int) -1
- && putc (':', stream) == EOF))
+ && putc_unlocked (':', stream) == EOF))
++errors;
if ((p->sp_inact != (long int) -1
&& fprintf (stream, "%ld:", p->sp_inact) < 0)
|| (p->sp_inact == (long int) -1
- && putc (':', stream) == EOF))
+ && putc_unlocked (':', stream) == EOF))
++errors;
if ((p->sp_expire != (long int) -1
&& fprintf (stream, "%ld:", p->sp_expire) < 0)
|| (p->sp_expire == (long int) -1
- && putc (':', stream) == EOF))
+ && putc_unlocked (':', stream) == EOF))
++errors;
if (p->sp_flag != ~0ul
&& fprintf (stream, "%ld", p->sp_flag) < 0)
++errors;
- if (putc ('\n', stream) == EOF)
+ if (putc_unlocked ('\n', stream) == EOF)
++errors;
+ funlockfile (stream);
+
return errors ? -1 : 0;
}
printf_size; printf_size_info;
# t*
- tmpfile64;
+ tmpfile; tmpfile64;
}
}
if (__gen_tempname (buf, 0, 0))
return NULL;
- return strdup (buf);
+ return __strdup (buf);
}
#include <stdio.h>
#include <unistd.h>
-#ifdef _USE_IN_LIBIO
-# define fdopen _IO_new_fdopen
+#ifdef USE_IN_LIBIO
+# include <iolibio.h>
+# define __fdopen _IO_fdopen
+# define tmpfile __new_tmpfile
#endif
/* This returns a new stream opened on a temporary file (generated
- by tmpnam) The file is opened with mode "w+b" (binary read/write).
+ by tmpnam). The file is opened with mode "w+b" (binary read/write).
If we couldn't generate a unique filename or the file couldn't
be opened, NULL is returned. */
FILE *
-tmpfile ()
+tmpfile (void)
{
char buf[FILENAME_MAX];
int fd;
if (__path_search (buf, FILENAME_MAX, NULL, "tmpf"))
return NULL;
- if ((fd = __gen_tempname (buf, 1, 0)) < 0)
+ fd = __gen_tempname (buf, 1, 0);
+ if (fd < 0)
return NULL;
/* Note that this relies on the Unix semantics that
a file is not really removed until it is closed. */
(void) remove (buf);
- if ((f = fdopen (fd, "w+b")) == NULL)
- close (fd);
+ if ((f = __fdopen (fd, "w+b")) == NULL)
+ __close (fd);
return f;
}
+
+#ifdef USE_IN_LIBIO
+# undef tmpfile
+# if defined PIC && DO_VERSIONING
+default_symbol_version (__new_tmpfile, tmpfile, GLIBC_2.1);
+# else
+# ifdef weak_alias
+weak_alias (__new_tmpfile, tmpfile)
+# endif
+# endif
+#endif
#include <stdio.h>
#include <unistd.h>
-#ifdef _USE_IN_LIBIO
-# define fdopen _IO_new_fdopen
+#ifdef USE_IN_LIBIO
+# include <iolibio.h>
+# define __fdopen _IO_fdopen
#endif
/* This returns a new stream opened on a temporary file (generated
if (__path_search (buf, FILENAME_MAX, NULL, "tmpf"))
return NULL;
- if ((fd = __gen_tempname (buf, 1, 1)) < 0)
+ fd = __gen_tempname (buf, 1, 1);
+ if (fd < 0)
return NULL;
/* Note that this relies on the Unix semantics that
a file is not really removed until it is closed. */
(void) remove (buf);
- if ((f = fdopen (fd, "w+b")) == NULL)
- close (fd);
+ if ((f = __fdopen (fd, "w+b")) == NULL)
+ __close (fd);
return f;
}
#ifdef __USE_POSIX
/* Create a new stream that refers to an existing system file descriptor. */
+extern FILE *__fdopen __P ((int __fd, __const char *__modes));
extern FILE *fdopen __P ((int __fd, __const char *__modes));
#endif
struct cmessage {
struct cmsghdr cmsg;
- struct cmsgcred cmcred;
+ struct ucred cmcred;
};
static int
static int
__msgwrite (int sock, void *buf, size_t cnt)
{
-#ifndef SCM_CREDS
+#ifndef SCM_CREDENTIALS
/* We cannot implement this reliably. */
__set_errno (ENOSYS);
return -1;
iov[0].iov_base = buf;
iov[0].iov_len = cnt;
- cm.cmsg.cmsg_type = SCM_CREDS;
+ cm.cmsg.cmsg_type = SCM_CREDENTIALS;
cm.cmsg.cmsg_level = SOL_SOCKET;
cm.cmsg.cmsg_len = sizeof (struct cmessage);
/* XXX I'm not sure, if gete?id() is always correct, or if we should use
get?id(). But since keyserv needs geteuid(), we have no other chance.
It would be much better, if the kernel could pass both to the server. */
- cm.cmcred.cmcred_pid = __getpid ();
- cm.cmcred.cmcred_uid = __geteuid ();
- cm.cmcred.cmcred_gid = __getegid ();
+ cm.cmcred.pid = __getpid ();
+ cm.cmcred.uid = __geteuid ();
+ cm.cmcred.gid = __getegid ();
msg.msg_iov = iov;
msg.msg_iovlen = 1;
#ifdef USE_IN_LIBIO
# include <libio/iolibio.h>
# define fflush(s) _IO_fflush (s)
+# define __fdopen(fd,m) _IO_fdopen (fd,m)
#endif
/*
/*
* parent: write into pdto[1], read from pdfrom[0]
*/
- *fto = fdopen (pdto[1], "w");
+ *fto = __fdopen (pdto[1], "w");
__close (pdto[0]);
- *ffrom = fdopen (pdfrom[0], "r");
+ *ffrom = __fdopen (pdfrom[0], "r");
__close (pdfrom[1]);
break;
}
struct cmessage {
struct cmsghdr cmsg;
- struct cmsgcred cmcred;
+ struct ucred cmcred;
};
/* XXX This is not thread safe, but since the main functions in svc.c
static int
__msgwrite (int sock, void *buf, size_t cnt)
{
-#ifndef SCM_CREDS
+#ifndef SCM_CREDENTIALS
/* We cannot implement this reliably. */
__set_errno (ENOSYS);
return -1;
iov[0].iov_base = buf;
iov[0].iov_len = cnt;
- cm.cmsg.cmsg_type = SCM_CREDS;
+ cm.cmsg.cmsg_type = SCM_CREDENTIALS;
cm.cmsg.cmsg_level = SOL_SOCKET;
cm.cmsg.cmsg_len = sizeof (struct cmessage);
/* XXX I'm not sure, if we really should use gete?id(), or get?id().
It would be much better, if the kernel could pass both to the
client. */
- cm.cmcred.cmcred_pid = __getpid ();
- cm.cmcred.cmcred_uid = __geteuid ();
- cm.cmcred.cmcred_gid = __getegid ();
+ cm.cmcred.pid = __getpid ();
+ cm.cmcred.uid = __geteuid ();
+ cm.cmcred.gid = __getegid ();
msg.msg_iov = iov;
msg.msg_iovlen = 1;
/* Macros to swap the order of bytes in integer values.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998 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
#endif
/* Swap bytes in 16 bit value. */
-#define __bswap_16(x) \
- ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
+#ifdef __GNUC__
+# define __bswap_16(x) \
+ (__extension__ \
+ ({ unsigned short int __bsx = (x); \
+ ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8)); }))
+#else
+static __inline unsigned short int
+__bswap16 (unsigned short int x)
+{
+ return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8));
+}
+#endif
/* Swap bytes in 32 bit value. */
-#define __bswap_32(x) \
- ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
- (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
+#ifdef __GNUC__
+# define __bswap_32(x) \
+ (__extension__ \
+ ({ unsigned int __bsx = (x); \
+ ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) | \
+ (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24)); }))
+#else
+static __inline unsigned int
+__bswap32 (unsigned int x)
+{
+ return ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) |
+ (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24));
+}
+#endif
#if defined __GNUC__ && __GNUC__ >= 2
/* Swap bytes in 64 bit value. */
-/* Copyright (C) 1991, 1992, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1996, 1997, 1998 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
};
/* Bits in `sa_flags'. */
-#ifdef __USE_BSD
-# define SA_ONSTACK 0x1 /* Take signal on signal stack. */
-# define SA_RESTART 0x2 /* Restart syscall on signal return. */
-# define SA_DISABLE 0x4 /* Disable alternate signal stack. */
+#if defined __USE_UNIX98 || defined __USE_MISC
+# define SA_ONSTACK 0x0001 /* Take signal on signal stack. */
+# define SA_RESTART 0x0002 /* Restart syscall on signal return. */
#endif
-#define SA_NOCLDSTOP 0x8 /* Don't send SIGCHLD when children stop. */
+#define SA_NOCLDSTOP 0x0008 /* Don't send SIGCHLD when children stop. */
/* Values for the HOW argument to `sigprocmask'. */
size_t ss_size;
int ss_flags;
} stack_t;
+
+
+/* Possible values for `ss_flags.'. */
+enum
+{
+ SS_ONSTACK = 0x0001,
+#define SS_ONSTACK SS_ONSTACK
+ SS_DISABLE = 0x0004,
+#define SS_DISABLE SS_DISABLE
+};
+
+/* Minumum stack size for a signal handler. */
+#define MINSIGSTKSZ 8192
+
+/* System default stack size. */
+#define SIGSTKSZ (MINSIGSTKSZ + 32768)
/* Open a new stream on a given system file descriptor. */
FILE *
-fdopen (fd, mode)
+__fdopen (fd, mode)
int fd;
const char *mode;
{
__set_errno (ENOSYS);
return NULL;
}
+weak_alias (__fdopen, fdopen)
stub_warning (fdopen)
#include <stub-tag.h>
/* Return from signal handler in GNU C library for Hurd. Alpha version.
- Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1994, 1995, 1997, 1998 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
if (scp->sc_onstack)
{
- ss->sigaltstack.ss_flags &= ~SA_ONSTACK; /* XXX threadvars */
+ ss->sigaltstack.ss_flags &= ~SS_ONSTACK; /* XXX threadvars */
/* XXX cannot unlock until off sigstack */
abort ();
}
/* Set thread_state for sighandler, and sigcontext to recover. Alpha version.
- Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1994, 1995, 1997, 1998 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
return NULL;
if ((ss->actions[signo].sa_flags & SA_ONSTACK) &&
- !(ss->sigaltstack.ss_flags & (SA_DISABLE|SA_ONSTACK)))
+ !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK)))
{
sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size;
- ss->sigaltstack.ss_flags |= SA_ONSTACK;
+ ss->sigaltstack.ss_flags |= SS_ONSTACK;
/* XXX need to set up base of new stack for
per-thread variables, cthreads. */
}
{
/* Set up the sigcontext from the current state of the thread. */
- scp->sc_onstack = ss->sigaltstack.ss_flags & SA_ONSTACK ? 1 : 0;
+ scp->sc_onstack = ss->sigaltstack.ss_flags & SS_ONSTACK ? 1 : 0;
/* struct sigcontext is laid out so that starting at sc_regs
mimics a struct alpha_thread_state. */
/* Open a new stream on a given system file descriptor. */
FILE *
-fdopen (fd, mode)
+__fdopen (fd, mode)
int fd;
const char *mode;
{
return stream;
}
+
+weak_alias (__fdopen, fdopen)
/* Set thread_state for sighandler, and sigcontext to recover. HPPA version.
- Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1997, 1998 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
return NULL;
if ((ss->actions[signo].sa_flags & SA_ONSTACK) &&
- !(ss->sigaltstack.ss_flags & (SA_DISABLE|SA_ONSTACK)))
+ !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK)))
{
sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size;
- ss->sigaltstack.ss_flags |= SA_ONSTACK;
+ ss->sigaltstack.ss_flags |= SS_ONSTACK;
/* XXX need to set up base of new stack for
per-thread variables, cthreads. */
}
/* Set up the sigcontext from the current state of the thread. */
- scp->sc_onstack = ss->sigaltstack.ss_flags & SA_ONSTACK ? 1 : 0;
+ scp->sc_onstack = ss->sigaltstack.ss_flags & SS_ONSTACK ? 1 : 0;
/* struct sigcontext is laid out so that starting at sc_regs mimics a
struct parisc_thread_state. */
-/* Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 94, 95, 96, 97, 98 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
if (scp->sc_onstack)
{
- ss->sigaltstack.ss_flags &= ~SA_ONSTACK; /* XXX threadvars */
+ ss->sigaltstack.ss_flags &= ~SS_ONSTACK; /* XXX threadvars */
/* XXX cannot unlock until off sigstack */
abort ();
}
/* Set thread_state for sighandler, and sigcontext to recover. i386 version.
- Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1994, 1995, 1996, 1997, 1998 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
state->basic.esp = state->basic.uesp;
if ((ss->actions[signo].sa_flags & SA_ONSTACK) &&
- !(ss->sigaltstack.ss_flags & (SA_DISABLE|SA_ONSTACK)))
+ !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK)))
{
sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size;
- ss->sigaltstack.ss_flags |= SA_ONSTACK;
+ ss->sigaltstack.ss_flags |= SS_ONSTACK;
/* XXX need to set up base of new stack for
per-thread variables, cthreads. */
}
/* Set up the sigcontext from the current state of the thread. */
- scp->sc_onstack = ss->sigaltstack.ss_flags & SA_ONSTACK ? 1 : 0;
+ scp->sc_onstack = ss->sigaltstack.ss_flags & SS_ONSTACK ? 1 : 0;
/* struct sigcontext is laid out so that starting at sc_gs mimics a
struct i386_thread_state. */
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 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
if (scp->sc_onstack)
{
- ss->sigaltstack.ss_flags &= ~SA_ONSTACK; /* XXX threadvars */
+ ss->sigaltstack.ss_flags &= ~SS_ONSTACK; /* XXX threadvars */
/* XXX cannot unlock until off sigstack */
abort ();
}
/* Set thread_state for sighandler, and sigcontext to recover. MIPS version.
- Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998 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
state->basic.r16 = state->basic.r29;
if ((ss->actions[signo].sa_flags & SA_ONSTACK) &&
- !(ss->sigaltstack.ss_flags & (SA_DISABLE|SA_ONSTACK)))
+ !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK)))
{
sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size;
- ss->sigaltstack.ss_flags |= SA_ONSTACK;
+ ss->sigaltstack.ss_flags |= SS_ONSTACK;
/* XXX need to set up base of new stack for
per-thread variables, cthreads. */
}
/* Set up the sigcontext from the current state of the thread. */
- scp->sc_onstack = ss->sigaltstack.ss_flags & SA_ONSTACK ? 1 : 0;
+ scp->sc_onstack = ss->sigaltstack.ss_flags & SS_ONSTACK ? 1 : 0;
/* struct sigcontext is laid out so that starting at sc_gpr
mimics a struct mips_thread_state. */
-/* Copyright (C) 1992, 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 93, 94, 95, 97, 98 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
/* Run signals handlers on the stack specified by SS (if not NULL).
If OSS is not NULL, it is filled in with the old signal stack status. */
int
-sigaltstack (argss, oss)
+__sigaltstack (argss, oss)
const struct sigaltstack *argss;
struct sigaltstack *oss;
{
__spin_lock (&s->lock);
if (argss != NULL &&
- (ss.ss_flags & SA_DISABLE) && (s->sigaltstack.ss_flags & SA_ONSTACK))
+ (ss.ss_flags & SS_DISABLE) && (s->sigaltstack.ss_flags & SS_ONSTACK))
{
/* Can't disable a stack that is in use. */
__spin_unlock (&s->lock);
return 0;
}
+weak_alias(__sigaltstack, sigaltstack)
-/* Copyright (C) 1992, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1997, 1998 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
/* Run signals handlers on the stack specified by SS (if not NULL).
If OSS is not NULL, it is filled in with the old signal stack status. */
-/* XXX should be __sigstack ? */
int
sigstack (ss, oss)
const struct sigstack *ss;
as.ss_size = 0;
as.ss_flags = 0;
- if (sigaltstack (&as, &oas) < 0)
+ if (__sigaltstack (&as, &oas) < 0)
return -1;
if (oss != NULL)
{
oss->ss_sp = oas.ss_sp;
- oss->ss_onstack = oas.ss_flags & SA_ONSTACK;
+ oss->ss_onstack = oas.ss_flags & SS_ONSTACK;
}
return 0;
/* Open a new stream on a given system file descriptor. */
FILE *
-fdopen (fd, mode)
+__fdopen (fd, mode)
int fd;
const char *mode;
{
return stream;
}
+
+weak_alias (__fdopen, fdopen)
if (openit)
{
- /* XXX Do we want to fail on largefile if 64 bit fileops
- are not implemented, or just fall back to the old stuff? */
-#ifndef __stub_open64
fd = (largefile
? __open (tmpl, O_RDWR | O_CREAT | O_EXCL, 0666)
: __open64 (tmpl, O_RDWR | O_CREAT | O_EXCL, 0666));
-#else
- fd = __open (tmpl, O_RDWR | O_CREAT | O_EXCL, 0666);
-#endif
if (fd >= 0)
{
__set_errno (save_errno);
sys/vt.h
xstatconv.c
getdents64.c
-__sendmsg.S
-__recvmsg.S
getresuid.c
getresgid.c
sysdep_headers += net/if.h net/if_ppp.h net/ppp-comp.h \
net/ppp_defs.h net/if_arp.h net/route.h net/ethernet.h \
net/if_slip.h net/if_packet.h
-sysdep_routines += cmsg_nxthdr sa_len __sendmsg __recvmsg
+sysdep_routines += cmsg_nxthdr sa_len
endif
ifeq ($(subdir),sunrpc)
+++ /dev/null
-#define socket ___syscall_recvmsg
-#define __socket __syscall_recvmsg
-#define SOCKOP____syscall_recvmsg SOCKOP_recvmsg
-#define NARGS 3
-#include <socket.S>
+++ /dev/null
-#define socket ___syscall_sendmsg
-#define __socket __syscall_sendmsg
-#define SOCKOP____syscall_sendmsg SOCKOP_sendmsg
-#define NARGS 3
-#include <socket.S>
SCM_RIGHTS = 0x01, /* Transfer file descriptors. */
#define SCM_RIGHTS SCM_RIGHTS
#ifdef __USE_BSD
- SCM_CREDS = 0x02, /* BSD-compatible credentials passing. */
-# define SCM_CREDS SCM_CREDS
+ SCM_CREDENTIALS = 0x02, /* Credentials passing. */
+# define SCM_CREDENTIALS SCM_CREDENTIALS
#endif
__SCM_CONNECT = 0x03, /* Data array is `struct scm_connect'. */
};
-#ifdef __USE_BSD
-
-/* User visible structure for SCM_CREDS message
- (chosen for BSD source compatibility) */
+/* User visible structure for SCM_CREDENTIALS message */
-# define CMGROUP_MAX 16 /* Linux does not provide this info, so it doesn't
- matter... use what bsd does. */
-struct cmsgcred
+struct ucred
{
- pid_t cmcred_pid; /* PID of sending process. */
- uid_t cmcred_uid; /* Real UID of sending process. */
- uid_t cmcred_euid; /* Effective UID of sending process. */
- gid_t cmcred_gid; /* Real GID of sending process. */
- short int cmcred_ngroups; /* Number or groups. */
- gid_t cmcred_groups[CMGROUP_MAX]; /* Groups. */
+ pid_t pid; /* PID of sending process. */
+ uid_t uid; /* UID of sending process. */
+ gid_t gid; /* GID of sending process. */
};
-#endif
/* Get socket manipulation related informations from kernel headers. */
#include <asm/socket.h>
--- /dev/null
+#define socket recvmsg
+#define __socket __libc_recvmsg
+#define NARGS 3
+#include <socket.S>
+++ /dev/null
-/* Copyright (C) 1998 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
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#include <sys/socket.h>
-#include <errno.h>
-#include <string.h>
-
-#include <asm/posix_types.h>
-
-/* The kernel expects this structure in SCM_CREDS messages.
- * Note: sizeof(struct __kernel_ucred) <= sizeof(struct cmsgcred) must hold.
- */
-struct __kernel_ucred
-{
- __kernel_pid_t pid;
- __kernel_uid_t uid;
- __kernel_gid_t gid;
-};
-
-extern int __syscall_recvmsg (int, struct msghdr *, int);
-
-int
-__libc_recvmsg (int fd, struct msghdr *message, int flags)
-{
- struct cmsghdr *cm;
- int ret;
-
- ret = __syscall_recvmsg (fd, message, flags);
-
- if (ret == -1)
- return ret;
-
- /* Postprocess the message control block for SCM_CREDS. */
- cm = CMSG_FIRSTHDR (message);
- while (cm)
- {
- if (cm->cmsg_type == SCM_CREDS)
- {
- struct cmsgcred *c = (struct cmsgcred *) CMSG_DATA (cm);
- struct __kernel_ucred u;
- int i;
- memcpy (&u, CMSG_DATA (cm), sizeof (struct __kernel_ucred));
-
- c->cmcred_pid = u.pid;
- c->cmcred_uid = u.uid;
- c->cmcred_gid = u.gid;
-
- c->cmcred_euid = -1;
- c->cmcred_ngroups = 0;
- for (i = 0; i < CMGROUP_MAX; i++)
- c->cmcred_groups[i] = -1;
- }
- cm = CMSG_NXTHDR (message, cm);
- }
-
- return ret;
-}
-
-weak_alias (__libc_recvmsg, recvmsg)
--- /dev/null
+#define socket sendmsg
+#define __socket __libc_sendmsg
+#define NARGS 3
+#include <socket.S>
+++ /dev/null
-/* Copyright (C) 1998 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
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#include <sys/socket.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <asm/posix_types.h>
-
-/* The kernel expects this structure in SCM_CREDS messages.
- * Note: sizeof(struct __kernel_ucred) <= sizeof(struct cmsgcred) must hold.
- */
-struct kernel_ucred
- {
- __kernel_pid_t pid;
- __kernel_uid_t uid;
- __kernel_gid_t gid;
- };
-
-struct credmsg
- {
- struct cmsghdr cm;
- struct cmsgcred cc;
- };
-
-struct kcredmsg
- {
- struct cmsghdr cm;
- struct kernel_ucred cc;
- };
-
-extern int __syscall_sendmsg (int, const struct msghdr *, int);
-
-/* Send a message described by MESSAGE on socket FD.
- Returns the number of bytes sent, or -1 for errors. */
-int
-__libc_sendmsg (int fd, const struct msghdr *message, int flags)
-{
- struct msghdr m;
- char *buf, *a, *b;
- struct credmsg *cred = 0;
- struct kcredmsg *kcred;
- struct cmsghdr *cm;
- long int offset = 0;
- pid_t pid;
-
- /* Preprocess the message control block for SCM_CREDS. */
- if (message->msg_controllen)
- {
- cm = CMSG_FIRSTHDR (message);
- while (cm)
- {
- if (cm->cmsg_type == SCM_CREDS)
- {
- if (cred ||
- cm->cmsg_len < CMSG_LEN (sizeof (struct cmsgcred)))
- {
- __set_errno (EINVAL);
- return -1;
- }
- else
- {
- cred = (struct credmsg *) cm;
- offset = (char *) cm - (char *) message->msg_control;
- }
- }
- cm = CMSG_NXTHDR ((struct msghdr *) message, cm);
- }
-
- if (cred)
- {
- buf = alloca (message->msg_controllen);
- memcpy (buf, message->msg_control, message->msg_controllen);
- kcred = (struct kcredmsg *) (buf + offset);
- a = (char *) kcred + CMSG_LEN (sizeof (struct kernel_ucred));
- b = (char *) kcred + CMSG_LEN (sizeof (struct cmsgcred));
- memmove (a, b, message->msg_controllen - (b - buf));
-
- kcred->cm.cmsg_len = CMSG_LEN (sizeof (struct kernel_ucred));
-
- /* Linux expects the calling process to pass in
- its credentials, and sanity checks them.
- You can send real, effective, or set- uid and gid.
- If the user hasn't filled in the buffer, we default to
- real uid and gid. */
- pid = __getpid ();
- if (cred->cc.cmcred_pid != pid)
- {
- kcred->cc.pid = pid;
- kcred->cc.uid = __getuid ();
- kcred->cc.gid = __getgid ();
- }
- else
- {
- kcred->cc.uid = cred->cc.cmcred_uid;
- kcred->cc.gid = cred->cc.cmcred_gid;
- }
- memcpy (&m, message, sizeof (struct msghdr));
- m.msg_control = buf;
- m.msg_controllen -= b - a;
- return __syscall_sendmsg (fd, &m, flags);
- }
- }
- return __syscall_sendmsg (fd, message, flags);
-}
-
-weak_alias (__libc_sendmsg, sendmsg)