PERFORCE change 141111 for review
Sam Leffler
sam at FreeBSD.org
Sat May 3 21:24:47 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=141111
Change 141111 by sam at sam_ebb on 2008/05/03 21:24:39
IFC @ 141110
Affected files ...
.. //depot/projects/vap/etc/defaults/rc.conf#12 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/kthr.c#6 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt.c#6 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_amd64.c#4 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_arm.c#4 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_i386.c#5 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_ia64.c#4 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c#4 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_sparc64.c#4 integrate
.. //depot/projects/vap/include/stdio.h#5 integrate
.. //depot/projects/vap/lib/csu/mips/Makefile#1 branch
.. //depot/projects/vap/lib/csu/mips/crt1.c#1 branch
.. //depot/projects/vap/lib/csu/mips/crti.S#1 branch
.. //depot/projects/vap/lib/csu/mips/crtn.S#1 branch
.. //depot/projects/vap/lib/libc/net/nsdispatch.c#4 integrate
.. //depot/projects/vap/lib/libc/stdio/Makefile.inc#3 integrate
.. //depot/projects/vap/lib/libc/stdio/clrerr.c#3 integrate
.. //depot/projects/vap/lib/libc/stdio/feof.c#3 integrate
.. //depot/projects/vap/lib/libc/stdio/ferror.c#3 integrate
.. //depot/projects/vap/lib/libc/stdio/fileno.c#3 integrate
.. //depot/projects/vap/lib/libc/stdio/getc.c#3 integrate
.. //depot/projects/vap/lib/libc/stdio/getchar.c#3 integrate
.. //depot/projects/vap/lib/libc/stdio/local.h#4 integrate
.. //depot/projects/vap/lib/libc/stdio/putc.c#3 integrate
.. //depot/projects/vap/lib/libc/stdio/putchar.c#3 integrate
.. //depot/projects/vap/lib/libc/stdio/stdio.c#3 integrate
.. //depot/projects/vap/lib/libc/stdio/unlocked.c#3 delete
.. //depot/projects/vap/lib/libc/stdio/xprintf.c#4 integrate
.. //depot/projects/vap/lib/libc/stdlib/malloc.c#9 integrate
.. //depot/projects/vap/lib/libc/stdlib/rb.h#2 integrate
.. //depot/projects/vap/lib/libftpio/ftpio.c#3 integrate
.. //depot/projects/vap/share/man/man4/auditpipe.4#3 integrate
.. //depot/projects/vap/share/man/man4/wlan.4#5 integrate
.. //depot/projects/vap/share/misc/bsd-family-tree#6 integrate
.. //depot/projects/vap/sys/amd64/conf/GENERIC#14 integrate
.. //depot/projects/vap/sys/conf/NOTES#17 integrate
.. //depot/projects/vap/sys/conf/files.sun4v#5 integrate
.. //depot/projects/vap/sys/dev/bge/if_bge.c#13 integrate
.. //depot/projects/vap/sys/dev/if_ndis/if_ndis.c#18 integrate
.. //depot/projects/vap/sys/dev/ipw/if_ipw.c#17 integrate
.. //depot/projects/vap/sys/dev/iwi/if_iwi.c#30 integrate
.. //depot/projects/vap/sys/dev/iwn/if_iwn.c#18 integrate
.. //depot/projects/vap/sys/dev/mpt/mpt.h#5 integrate
.. //depot/projects/vap/sys/dev/mpt/mpt_cam.c#3 integrate
.. //depot/projects/vap/sys/dev/mpt/mpt_raid.c#3 integrate
.. //depot/projects/vap/sys/dev/ral/rt2560.c#33 integrate
.. //depot/projects/vap/sys/dev/ral/rt2661.c#31 integrate
.. //depot/projects/vap/sys/dev/usb/if_rum.c#22 integrate
.. //depot/projects/vap/sys/dev/usb/if_zyd.c#21 integrate
.. //depot/projects/vap/sys/dev/usb/ums.c#7 integrate
.. //depot/projects/vap/sys/dev/usb/usbdevs#17 integrate
.. //depot/projects/vap/sys/dev/wi/if_wi.c#30 integrate
.. //depot/projects/vap/sys/dev/wpi/if_wpi.c#23 integrate
.. //depot/projects/vap/sys/i386/conf/GENERIC#14 integrate
.. //depot/projects/vap/sys/i386/cpufreq/est.c#9 integrate
.. //depot/projects/vap/sys/kern/uipc_mbuf.c#10 integrate
.. //depot/projects/vap/sys/mips/include/am29lv081b.h#2 delete
.. //depot/projects/vap/sys/mips/include/cp0.h#2 delete
.. //depot/projects/vap/sys/mips/include/float.h#2 integrate
.. //depot/projects/vap/sys/mips/mips/mips_subr.c#2 delete
.. //depot/projects/vap/sys/modules/wlan/Makefile#10 integrate
.. //depot/projects/vap/sys/net80211/ieee80211.c#43 integrate
.. //depot/projects/vap/sys/net80211/ieee80211_node.c#31 integrate
.. //depot/projects/vap/sys/netinet/libalias/alias.c#7 integrate
.. //depot/projects/vap/sys/pc98/conf/GENERIC#12 integrate
.. //depot/projects/vap/sys/sparc64/conf/GENERIC#13 integrate
.. //depot/projects/vap/sys/sparc64/pci/ofw_pcibus.c#7 integrate
.. //depot/projects/vap/sys/sun4v/include/bus_common.h#3 delete
.. //depot/projects/vap/sys/sun4v/sun4v/nexus.c#3 integrate
.. //depot/projects/vap/sys/sun4v/sun4v/vnex.c#3 integrate
.. //depot/projects/vap/tools/tools/mfc/mfc.pl#3 integrate
.. //depot/projects/vap/tools/tools/net80211/wlanstats/main.c#8 integrate
.. //depot/projects/vap/tools/tools/net80211/wlanstats/statfoo.c#5 integrate
.. //depot/projects/vap/tools/tools/net80211/wlanstats/statfoo.h#5 integrate
.. //depot/projects/vap/tools/tools/net80211/wlanstats/wlanstats.c#12 integrate
.. //depot/projects/vap/tools/tools/net80211/wlanwatch/wlanwatch.c#8 integrate
.. //depot/projects/vap/usr.bin/tar/bsdtar.1#6 integrate
.. //depot/projects/vap/usr.bin/tar/bsdtar.c#6 integrate
.. //depot/projects/vap/usr.bin/tar/test/Makefile#1 branch
.. //depot/projects/vap/usr.bin/tar/test/main.c#1 branch
.. //depot/projects/vap/usr.bin/tar/test/test.h#1 branch
.. //depot/projects/vap/usr.bin/tar/test/test_0.c#1 branch
.. //depot/projects/vap/usr.bin/tar/test/test_basic.c#1 branch
.. //depot/projects/vap/usr.bin/tar/test/test_copy.c#1 branch
.. //depot/projects/vap/usr.bin/tar/test/test_getdate.c#1 branch
.. //depot/projects/vap/usr.bin/tar/test/test_help.c#1 branch
.. //depot/projects/vap/usr.bin/tar/test/test_option_T.c#1 branch
.. //depot/projects/vap/usr.bin/tar/test/test_stdio.c#1 branch
.. //depot/projects/vap/usr.bin/tar/test/test_version.c#1 branch
.. //depot/projects/vap/usr.bin/tar/write.c#5 integrate
.. //depot/projects/vap/usr.bin/tip/tip/cmds.c#3 integrate
.. //depot/projects/vap/usr.bin/tip/tip/tip.c#3 integrate
.. //depot/projects/vap/usr.bin/tip/tip/tip.h#3 integrate
.. //depot/projects/vap/usr.bin/tip/tip/uucplock.c#3 integrate
.. //depot/projects/vap/usr.bin/unifdef/unifdef.1#3 integrate
.. //depot/projects/vap/usr.sbin/sade/Makefile#3 integrate
Differences ...
==== //depot/projects/vap/etc/defaults/rc.conf#12 (text+ko) ====
@@ -15,7 +15,7 @@
# For a more detailed explanation of all the rc.conf variables, please
# refer to the rc.conf(5) manual page.
#
-# $FreeBSD: src/etc/defaults/rc.conf,v 1.333 2008/04/23 22:40:59 brooks Exp $
+# $FreeBSD: src/etc/defaults/rc.conf,v 1.334 2008/05/03 07:06:48 brooks Exp $
##############################################################
### Important initial Boot-time options ####################
@@ -184,7 +184,7 @@
#ifconfig_lo0_alias0="inet 127.0.0.254 netmask 0xffffffff" # Sample alias entry.
#ifconfig_ed0_ipx="ipx 0x00010010" # Sample IPX address family entry.
#ifconfig_fxp0_name="net0" # Change interface name from fxp0 to net0.
-#vaps_ath0="wlan0" # VAP interfaces for ath0 device
+#wlans_ath0="wlan0" # wlan(4) interfaces for ath0 device
#ipv4_addrs_fxp0="192.168.0.1/24 192.168.1.1-5/28" # example IPv4 address entry.
#
#autobridge_interfaces="bridge0" # List of bridges to check
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/kthr.c#6 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/kthr.c,v 1.11 2008/04/29 20:32:45 jhb Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/kthr.c,v 1.12 2008/05/01 20:36:48 jhb Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -218,21 +218,24 @@
struct kthr *kt;
struct proc *p;
struct thread *t;
- static char info[MAXCOMLEN + 1 + MAXCOMLEN + 1];
+ static char buf[64];
kt = kgdb_thr_lookup_tid(tid);
if (kt == NULL)
- return (NULL);
+ return (NULL);
+ snprintf(buf, sizeof(buf), "PID=%d", kt->pid);
p = (struct proc *)kt->paddr;
- t = (struct thread *)kt->kaddr;
if (kvm_read(kvm, (uintptr_t)&p->p_comm[0], &comm, sizeof(comm)) !=
sizeof(comm))
- return (NULL);
+ return (buf);
+ strlcat(buf, ": ", sizeof(buf));
+ strlcat(buf, comm, sizeof(buf));
+ t = (struct thread *)kt->kaddr;
if (kvm_read(kvm, (uintptr_t)&t->td_name[0], &td_name,
sizeof(td_name)) == sizeof(td_name) &&
- strcmp(comm, td_name) != 0)
- snprintf(info, sizeof(info), "%s/%s", comm, td_name);
- else
- strlcpy(info, comm, sizeof(info));
- return (info);
+ strcmp(comm, td_name) != 0) {
+ strlcat(buf, "/", sizeof(buf));
+ strlcat(buf, td_name, sizeof(buf));
+ }
+ return (buf);
}
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt.c#6 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt.c,v 1.11 2008/04/29 20:32:45 jhb Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt.c,v 1.12 2008/05/01 20:36:48 jhb Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -41,6 +41,7 @@
#include <command.h>
#include <exec.h>
#include <frame-unwind.h>
+#include <gdb.h>
#include <gdbcore.h>
#include <gdbthread.h>
#include <inferior.h>
@@ -48,6 +49,7 @@
#include <regcache.h>
#include <solib.h>
#include <target.h>
+#include <ui-out.h>
#include "kgdb.h"
@@ -125,11 +127,11 @@
init_thread_list();
kt = kgdb_thr_init();
while (kt != NULL) {
- ti = add_thread(ptid_build(kt->pid, 0, kt->tid));
+ ti = add_thread(pid_to_ptid(kt->tid));
kt = kgdb_thr_next(kt);
}
if (curkthr != 0)
- inferior_ptid = ptid_build(curkthr->pid, 0, curkthr->tid);
+ inferior_ptid = pid_to_ptid(curkthr->tid);
if (ontop) {
/* XXX: fetch registers? */
@@ -187,14 +189,8 @@
static char *
kgdb_trgt_extra_thread_info(struct thread_info *ti)
{
- static char buf[64];
- char *p, *s;
- p = buf + snprintf(buf, sizeof(buf), "PID=%d", ptid_get_pid(ti->ptid));
- s = kgdb_thr_extra_thread_info(ptid_get_tid(ti->ptid));
- if (s != NULL)
- snprintf(p, sizeof(buf) - (p - buf), ": %s", s);
- return (buf);
+ return (kgdb_thr_extra_thread_info(ptid_get_pid(ti->ptid)));
}
static void
@@ -224,14 +220,14 @@
{
static char buf[33];
- snprintf(buf, sizeof(buf), "Thread %ld", ptid_get_tid(ptid));
+ snprintf(buf, sizeof(buf), "Thread %d", ptid_get_pid(ptid));
return (buf);
}
static int
kgdb_trgt_thread_alive(ptid_t ptid)
{
- return (kgdb_thr_lookup_tid(ptid_get_tid(ptid)) != NULL);
+ return (kgdb_thr_lookup_tid(ptid_get_pid(ptid)) != NULL);
}
static int
@@ -260,16 +256,16 @@
}
static void
-kgdb_switch_to_thread(struct kthr *thr)
+kgdb_switch_to_thread(int tid)
{
- if (thr->tid == ptid_get_tid(inferior_ptid))
- return;
+ char buf[16];
+ int thread_id;
- inferior_ptid = ptid_build(thr->pid, 0, thr->tid);
- flush_cached_frames ();
- registers_changed ();
- stop_pc = read_pc ();
- select_frame (get_current_frame ());
+ thread_id = pid_to_thread_id(pid_to_ptid(tid));
+ if (thread_id == 0)
+ error ("invalid tid");
+ snprintf(buf, sizeof(buf), "%d", thread_id);
+ gdb_thread_select(uiout, buf);
}
static void
@@ -282,7 +278,7 @@
error_no_arg ("proc address for the new context");
if (kvm == NULL)
- error ("no kernel core file");
+ error ("only supported for core file target");
addr = (CORE_ADDR) parse_and_eval_address (arg);
@@ -295,7 +291,7 @@
if (thr == NULL)
error("invalid proc address");
}
- kgdb_switch_to_thread(thr);
+ kgdb_switch_to_thread(thr->tid);
}
static void
@@ -307,21 +303,15 @@
if (!arg)
error_no_arg ("TID or thread address for the new context");
- if (kvm == NULL)
- error ("no kernel core file");
-
addr = (CORE_ADDR) parse_and_eval_address (arg);
- if (!INKERNEL (addr)) {
- thr = kgdb_thr_lookup_tid((int)addr);
- if (thr == NULL)
- error ("invalid TID");
- } else {
+ if (kvm != NULL && INKERNEL (addr)) {
thr = kgdb_thr_lookup_taddr(addr);
if (thr == NULL)
error("invalid thread address");
+ addr = thr->tid;
}
- kgdb_switch_to_thread(thr);
+ kgdb_switch_to_thread(addr);
}
int fbsdcoreops_suppress_target = 1;
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_amd64.c#4 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt_amd64.c,v 1.9 2008/04/29 20:32:45 jhb Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt_amd64.c,v 1.10 2008/05/01 20:36:48 jhb Exp $");
#include <sys/types.h>
#include <machine/pcb.h>
@@ -50,7 +50,7 @@
struct kthr *kt;
struct pcb pcb;
- kt = kgdb_thr_lookup_tid(ptid_get_tid(inferior_ptid));
+ kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid));
if (kt == NULL)
return;
if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) {
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_arm.c#4 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt_arm.c,v 1.4 2008/04/29 20:32:45 jhb Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt_arm.c,v 1.5 2008/05/01 20:36:48 jhb Exp $");
#include <sys/types.h>
#ifndef CROSS_DEBUGGER
@@ -55,7 +55,7 @@
struct pcb pcb;
int i, reg;
- kt = kgdb_thr_lookup_tid(ptid_get_tid(inferior_ptid));
+ kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid));
if (kt == NULL)
return;
if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) {
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_i386.c#5 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt_i386.c,v 1.10 2008/04/29 20:32:45 jhb Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt_i386.c,v 1.11 2008/05/01 20:36:48 jhb Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -56,7 +56,7 @@
struct kthr *kt;
struct pcb pcb;
- kt = kgdb_thr_lookup_tid(ptid_get_tid(inferior_ptid));
+ kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid));
if (kt == NULL)
return;
if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) {
@@ -133,7 +133,7 @@
struct segment_descriptor sd;
uintptr_t addr, cpu0prvpage, tss;
- kt = kgdb_thr_lookup_tid(ptid_get_tid(inferior_ptid));
+ kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid));
if (kt == NULL || kt->cpu == NOCPU)
return (0);
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_ia64.c#4 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt_ia64.c,v 1.5 2008/04/29 20:32:45 jhb Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt_ia64.c,v 1.6 2008/05/01 20:36:48 jhb Exp $");
#include <sys/types.h>
#include <machine/frame.h>
@@ -52,7 +52,7 @@
struct pcb pcb;
uint64_t r;
- kt = kgdb_thr_lookup_tid(ptid_get_tid(inferior_ptid));
+ kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid));
if (kt == NULL)
return;
if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) {
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c#4 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c,v 1.3 2008/04/29 20:32:45 jhb Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c,v 1.4 2008/05/01 20:36:48 jhb Exp $");
#include <sys/types.h>
#include <machine/pcb.h>
@@ -54,7 +54,7 @@
tdep = gdbarch_tdep (current_gdbarch);
- kt = kgdb_thr_lookup_tid(ptid_get_tid(inferior_ptid));
+ kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid));
if (kt == NULL)
return;
if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) {
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_sparc64.c#4 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt_sparc64.c,v 1.7 2008/04/29 20:32:45 jhb Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt_sparc64.c,v 1.8 2008/05/01 20:36:48 jhb Exp $");
#include <sys/types.h>
#include <machine/asm.h>
@@ -52,7 +52,7 @@
struct kthr *kt;
struct pcb pcb;
- kt = kgdb_thr_lookup_tid(ptid_get_tid(inferior_ptid));
+ kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid));
if (kt == NULL)
return;
if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) {
==== //depot/projects/vap/include/stdio.h#5 (text+ko) ====
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)stdio.h 8.5 (Berkeley) 4/29/95
- * $FreeBSD: src/include/stdio.h,v 1.64 2008/04/17 22:17:53 jhb Exp $
+ * $FreeBSD: src/include/stdio.h,v 1.68 2008/05/03 20:09:44 marcel Exp $
*/
#ifndef _STDIO_H_
@@ -60,85 +60,9 @@
#define _FSTDIO /* Define for new stdio with functions. */
-/*
- * NB: to fit things in six character monocase externals, the stdio
- * code uses the prefix `__s' for stdio objects, typically followed
- * by a three-character attempt at a mnemonic.
- */
-
-/* stdio buffers */
-struct __sbuf {
- unsigned char *_base;
- int _size;
-};
-
-/*
- * stdio state variables.
- *
- * The following always hold:
- *
- * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
- * _lbfsize is -_bf._size, else _lbfsize is 0
- * if _flags&__SRD, _w is 0
- * if _flags&__SWR, _r is 0
- *
- * This ensures that the getc and putc macros (or inline functions) never
- * try to write or read from a file that is in `read' or `write' mode.
- * (Moreover, they can, and do, automatically switch from read mode to
- * write mode, and back, on "r+" and "w+" files.)
- *
- * _lbfsize is used only to make the inline line-buffered output stream
- * code as compact as possible.
- *
- * _ub, _up, and _ur are used when ungetc() pushes back more characters
- * than fit in the current _bf, or when ungetc() pushes back a character
- * that does not match the previous one in _bf. When this happens,
- * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
- * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
- *
- * Certain members of __sFILE are accessed directly via macros or
- * inline functions. To preserve ABI compat, these members must not
- * be disturbed. These members are marked below with (*).
- */
-typedef struct __sFILE {
- unsigned char *_p; /* (*) current position in (some) buffer */
- int _r; /* (*) read space left for getc() */
- int _w; /* (*) write space left for putc() */
- short _flags; /* (*) flags, below; this FILE is free if 0 */
- short _file; /* (*) fileno, if Unix descriptor, else -1 */
- struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
- int _lbfsize; /* (*) 0 or -_bf._size, for inline putc */
+struct __sFILE;
+typedef struct __sFILE FILE;
- /* operations */
- void *_cookie; /* cookie passed to io functions */
- int (*_close)(void *);
- int (*_read)(void *, char *, int);
- fpos_t (*_seek)(void *, fpos_t, int);
- int (*_write)(void *, const char *, int);
-
- /* separate buffer for long sequences of ungetc() */
- struct __sbuf _ub; /* ungetc buffer */
- unsigned char *_up; /* saved _p when _p is doing ungetc data */
- int _ur; /* saved _r when _r is counting ungetc data */
-
- /* tricks to meet minimum requirements even when malloc() fails */
- unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
- unsigned char _nbuf[1]; /* guarantee a getc() buffer */
-
- /* separate buffer for fgetln() when line crosses buffer boundary */
- struct __sbuf _lb; /* buffer for fgetln() */
-
- /* Unix stdio files get aligned to block boundaries on fseek() */
- int _blksize; /* stat.st_blksize (may be != _bf._size) */
- fpos_t _offset; /* current lseek offset */
-
- struct pthread_mutex *_fl_mutex; /* used for MT-safety */
- struct pthread *_fl_owner; /* current owner */
- int _fl_count; /* recursive lock count */
- int _orientation; /* orientation for fwide() */
- __mbstate_t _mbstate; /* multibyte conversion state */
-} FILE;
-
#ifndef _STDSTREAM_DECLARED
__BEGIN_DECLS
extern FILE *__stdinp;
@@ -148,32 +72,11 @@
#define _STDSTREAM_DECLARED
#endif
-#define __SLBF 0x0001 /* line buffered */
-#define __SNBF 0x0002 /* unbuffered */
-#define __SRD 0x0004 /* OK to read */
-#define __SWR 0x0008 /* OK to write */
- /* RD and WR are never simultaneously asserted */
-#define __SRW 0x0010 /* open for reading & writing */
-#define __SEOF 0x0020 /* found EOF */
-#define __SERR 0x0040 /* found error */
-#define __SMBF 0x0080 /* _buf is from malloc */
-#define __SAPP 0x0100 /* fdopen()ed in append mode */
-#define __SSTR 0x0200 /* this is an sprintf/snprintf string */
-#define __SOPT 0x0400 /* do fseek() optimization */
-#define __SNPT 0x0800 /* do not do fseek() optimization */
-#define __SOFF 0x1000 /* set iff _offset is in fact correct */
-#define __SMOD 0x2000 /* true => fgetln modified _p text */
-#define __SALC 0x4000 /* allocate string space dynamically */
-#define __SIGN 0x8000 /* ignore this file in _fwalk */
-
/*
* The following three definitions are for ANSI C, which took them
* from System V, which brilliantly took internal interface macros and
* made them official arguments to setvbuf(), without renaming them.
* Hence, these ugly _IOxxx names are *supposed* to appear in user code.
- *
- * Although numbered as their counterparts above, the implementation
- * does not rely on this.
*/
#define _IOFBF 0 /* setvbuf should set fully buffered */
#define _IOLBF 1 /* setvbuf should set line buffered */
@@ -301,8 +204,8 @@
void funlockfile(FILE *);
/*
- * These are normally used through macros as defined below, but POSIX
- * requires functions as well.
+ * See ISO/IEC 9945-1 ANSI/IEEE Std 1003.1 Second Edition 1996-07-12
+ * B.8.2.7 for the rationale behind the *_unlocked() functions.
*/
int getc_unlocked(FILE *);
int getchar_unlocked(void);
@@ -310,10 +213,10 @@
int putchar_unlocked(int);
#endif
#if __BSD_VISIBLE
-void clearerr_unlocked(FILE *);
-int feof_unlocked(FILE *);
-int ferror_unlocked(FILE *);
-int fileno_unlocked(FILE *);
+void clearerr_unlocked(FILE *);
+int feof_unlocked(FILE *);
+int ferror_unlocked(FILE *);
+int fileno_unlocked(FILE *);
#endif
#if __POSIX_VISIBLE >= 200112
@@ -336,15 +239,19 @@
#if __BSD_VISIBLE
int asprintf(char **, const char *, ...) __printflike(2, 3);
char *ctermid_r(char *);
-void fcloseall(void);
+void fcloseall(void);
char *fgetln(FILE *, size_t *);
__const char *fmtcheck(const char *, const char *) __format_arg(2);
int fpurge(FILE *);
+int renameat(int, const char *, int, const char *);
void setbuffer(FILE *, char *, int);
int setlinebuf(FILE *);
int vasprintf(char **, const char *, __va_list)
__printflike(2, 0);
+void *__fgetcookie(FILE *);
+void __fsetfileno(FILE *, int);
+
/*
* The system error table contains messages for the first sys_nerr
* positive errno values. Use strerror() or strerror_r() from <string.h>
@@ -385,79 +292,5 @@
#endif
#endif /* __BSD_VISIBLE */
-/*
- * Functions internal to the implementation.
- */
-int __srget(FILE *);
-int __swbuf(int, FILE *);
-
-/*
- * The __sfoo macros are here so that we can
- * define function versions in the C library.
- */
-#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++))
-#if defined(__GNUC__) && defined(__STDC__)
-static __inline int __sputc(int _c, FILE *_p) {
- if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
- return (*_p->_p++ = _c);
- else
- return (__swbuf(_c, _p));
-}
-#else
-/*
- * This has been tuned to generate reasonable code on the vax using pcc.
- */
-#define __sputc(c, p) \
- (--(p)->_w < 0 ? \
- (p)->_w >= (p)->_lbfsize ? \
- (*(p)->_p = (c)), *(p)->_p != '\n' ? \
- (int)*(p)->_p++ : \
- __swbuf('\n', p) : \
- __swbuf((int)(c), p) : \
- (*(p)->_p = (c), (int)*(p)->_p++))
-#endif
-
-#define __sfeof(p) (((p)->_flags & __SEOF) != 0)
-#define __sferror(p) (((p)->_flags & __SERR) != 0)
-#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
-#define __sfileno(p) ((p)->_file)
-
-extern int __isthreaded;
-
-#define feof(p) (!__isthreaded ? __sfeof(p) : (feof)(p))
-#define ferror(p) (!__isthreaded ? __sferror(p) : (ferror)(p))
-#define clearerr(p) (!__isthreaded ? __sclearerr(p) : (clearerr)(p))
-
-#if __POSIX_VISIBLE
-#define fileno(p) (!__isthreaded ? __sfileno(p) : (fileno)(p))
-#endif
-
-#define getc(fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp))
-#define putc(x, fp) (!__isthreaded ? __sputc(x, fp) : (putc)(x, fp))
-
-#define getchar() getc(stdin)
-#define putchar(x) putc(x, stdout)
-
-#if __BSD_VISIBLE
-/*
- * See ISO/IEC 9945-1 ANSI/IEEE Std 1003.1 Second Edition 1996-07-12
- * B.8.2.7 for the rationale behind the *_unlocked() macros.
- */
-#define feof_unlocked(p) __sfeof(p)
-#define ferror_unlocked(p) __sferror(p)
-#define clearerr_unlocked(p) __sclearerr(p)
-#define fileno_unlocked(p) __sfileno(p)
-#endif
-#if __POSIX_VISIBLE >= 199506
-#define getc_unlocked(fp) __sgetc(fp)
-#define putc_unlocked(x, fp) __sputc(x, fp)
-
-#define getchar_unlocked() getc_unlocked(stdin)
-#define putchar_unlocked(x) putc_unlocked(x, stdout)
-#endif
-
-#if __BSD_VISIBLE
-int renameat(int, const char *, int, const char *);
-#endif
__END_DECLS
#endif /* !_STDIO_H_ */
==== //depot/projects/vap/lib/libc/net/nsdispatch.c#4 (text+ko) ====
@@ -68,7 +68,7 @@
*
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/net/nsdispatch.c,v 1.16 2007/12/17 16:12:57 bushman Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/net/nsdispatch.c,v 1.17 2008/05/02 14:51:22 jhb Exp $");
#include "namespace.h"
#include <sys/param.h>
@@ -86,6 +86,7 @@
#include <syslog.h>
#include <unistd.h>
#include "un-namespace.h"
+#include "libc_private.h"
#ifdef NS_CACHING
#include "nscache.h"
#endif
==== //depot/projects/vap/lib/libc/stdio/Makefile.inc#3 (text+ko) ====
@@ -1,5 +1,5 @@
# @(#)Makefile.inc 8.3 (Berkeley) 4/17/94
-# $FreeBSD: src/lib/libc/stdio/Makefile.inc,v 1.37 2006/04/22 15:09:15 deischen Exp $
+# $FreeBSD: src/lib/libc/stdio/Makefile.inc,v 1.38 2008/05/02 15:25:07 jhb Exp $
# stdio sources
.PATH: ${.CURDIR}/stdio
@@ -16,7 +16,7 @@
refill.c remove.c rewind.c rget.c scanf.c setbuf.c setbuffer.c \
setvbuf.c snprintf.c sprintf.c sscanf.c stdio.c swprintf.c swscanf.c \
tempnam.c tmpfile.c \
- tmpnam.c ungetc.c ungetwc.c unlocked.c vasprintf.c vfprintf.c \
+ tmpnam.c ungetc.c ungetwc.c vasprintf.c vfprintf.c \
vfscanf.c \
vfwprintf.c vfwscanf.c vprintf.c vscanf.c vsnprintf.c vsprintf.c \
vsscanf.c \
==== //depot/projects/vap/lib/libc/stdio/clrerr.c#3 (text+ko) ====
@@ -34,13 +34,15 @@
static char sccsid[] = "@(#)clrerr.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/stdio/clrerr.c,v 1.10 2007/01/09 00:28:06 imp Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/stdio/clrerr.c,v 1.11 2008/05/02 15:25:07 jhb Exp $");
#include "namespace.h"
#include <stdio.h>
#include "un-namespace.h"
+#include "local.h"
#include "libc_private.h"
-#undef clearerr
+
+#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
void
clearerr(fp)
@@ -50,3 +52,10 @@
__sclearerr(fp);
FUNLOCKFILE(fp);
}
+
+void
+clearerr_unlocked(FILE *fp)
+{
+
+ __sclearerr(fp);
+}
==== //depot/projects/vap/lib/libc/stdio/feof.c#3 (text+ko) ====
@@ -34,14 +34,15 @@
static char sccsid[] = "@(#)feof.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/stdio/feof.c,v 1.10 2007/01/09 00:28:06 imp Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/stdio/feof.c,v 1.11 2008/05/02 15:25:07 jhb Exp $");
#include "namespace.h"
#include <stdio.h>
#include "un-namespace.h"
+#include "local.h"
#include "libc_private.h"
-#undef feof
+#define __sfeof(p) (((p)->_flags & __SEOF) != 0)
int
feof(FILE *fp)
@@ -53,3 +54,10 @@
FUNLOCKFILE(fp);
return (ret);
}
+
+int
+feof_unlocked(FILE *fp)
+{
+
+ return (__sfeof(fp));
+}
==== //depot/projects/vap/lib/libc/stdio/ferror.c#3 (text+ko) ====
@@ -34,15 +34,14 @@
static char sccsid[] = "@(#)ferror.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/stdio/ferror.c,v 1.10 2007/01/09 00:28:06 imp Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/stdio/ferror.c,v 1.11 2008/05/02 15:25:07 jhb Exp $");
#include "namespace.h"
#include <stdio.h>
#include "un-namespace.h"
+#include "local.h"
#include "libc_private.h"
-#undef ferror
-
int
ferror(FILE *fp)
{
@@ -53,3 +52,10 @@
FUNLOCKFILE(fp);
return (ret);
}
+
+int
+ferror_unlocked(FILE *fp)
+{
+
+ return (__sferror(fp));
+}
==== //depot/projects/vap/lib/libc/stdio/fileno.c#3 (text+ko) ====
@@ -34,14 +34,15 @@
static char sccsid[] = "@(#)fileno.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/stdio/fileno.c,v 1.11 2007/01/09 00:28:06 imp Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/stdio/fileno.c,v 1.12 2008/05/02 15:25:07 jhb Exp $");
#include "namespace.h"
#include <stdio.h>
#include "un-namespace.h"
+#include "local.h"
#include "libc_private.h"
-#undef fileno
+#define __sfileno(p) ((p)->_file)
int
fileno(FILE *fp)
@@ -54,3 +55,10 @@
return (fd);
}
+
+int
+fileno_unlocked(FILE *fp)
+{
+
+ return (__sfileno(fp));
+}
==== //depot/projects/vap/lib/libc/stdio/getc.c#3 (text+ko) ====
@@ -34,7 +34,7 @@
static char sccsid[] = "@(#)getc.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/stdio/getc.c,v 1.14 2007/01/09 00:28:06 imp Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/stdio/getc.c,v 1.15 2008/05/02 15:25:07 jhb Exp $");
#include "namespace.h"
#include <stdio.h>
@@ -42,8 +42,6 @@
#include "libc_private.h"
#include "local.h"
-#undef getc
-
int
getc(FILE *fp)
{
@@ -55,3 +53,10 @@
FUNLOCKFILE(fp);
return (retval);
}
+
+int
+getc_unlocked(FILE *fp)
+{
+
+ return (__sgetc(fp));
+}
==== //depot/projects/vap/lib/libc/stdio/getchar.c#3 (text+ko) ====
@@ -34,7 +34,7 @@
static char sccsid[] = "@(#)getchar.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/stdio/getchar.c,v 1.13 2007/01/09 00:28:06 imp Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/stdio/getchar.c,v 1.14 2008/05/02 15:25:07 jhb Exp $");
/*
* A subroutine version of the macro getchar.
@@ -45,8 +45,6 @@
#include "local.h"
#include "libc_private.h"
-#undef getchar
-
int
getchar()
{
@@ -58,3 +56,10 @@
FUNLOCKFILE(stdin);
return (retval);
}
+
+int
+getchar_unlocked(void)
+{
+
+ return (__sgetc(stdin));
+}
==== //depot/projects/vap/lib/libc/stdio/local.h#4 (text+ko) ====
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*
* @(#)local.h 8.3 (Berkeley) 7/3/94
- * $FreeBSD: src/lib/libc/stdio/local.h,v 1.31 2008/04/17 22:17:54 jhb Exp $
+ * $FreeBSD: src/lib/libc/stdio/local.h,v 1.32 2008/05/02 15:25:07 jhb Exp $
*/
#include <sys/types.h> /* for off_t */
@@ -39,9 +39,105 @@
#include <wchar.h>
/*
- * Information local to this implementation of stdio,
- * in particular, macros and private variables.
+ * Information local to this implementation of stdio, in particular,
+ * macros, private functions, private variables, and the definition of
+ * FILE.
+ *
+ * NB: to fit things in six character monocase externals, the stdio
+ * code uses the prefix `__s' for stdio objects, typically followed
+ * by a three-character attempt at a mnemonic.
+ */
+
+/* stdio buffers */
+struct __sbuf {
+ unsigned char *_base;
+ int _size;
+};
+
+/*
+ * stdio state variables.
+ *
+ * The following always hold:
+ *
+ * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
+ * _lbfsize is -_bf._size, else _lbfsize is 0
+ * if _flags&__SRD, _w is 0
+ * if _flags&__SWR, _r is 0
+ *
+ * This ensures that the getc and putc macros (or inline functions) never
+ * try to write or read from a file that is in `read' or `write' mode.
+ * (Moreover, they can, and do, automatically switch from read mode to
+ * write mode, and back, on "r+" and "w+" files.)
+ *
+ * _lbfsize is used only to make the inline line-buffered output stream
+ * code as compact as possible.
+ *
+ * _ub, _up, and _ur are used when ungetc() pushes back more characters
+ * than fit in the current _bf, or when ungetc() pushes back a character
+ * that does not match the previous one in _bf. When this happens,
+ * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
+ * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
+ *
+ * Certain members of __sFILE are accessed directly via macros or
+ * inline functions. To preserve ABI compat, these members must not
+ * be disturbed. These members are marked below with (*).
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list