Compare commits

...
172 Commits
Author SHA1 Message Date
Peter Wemm 1ebb47c83a Mention FreeBSD-SA-05:03.amd64, bump patchlevel.
Approved by:  so (cperciva)
2005-04-06 02:10:53 +00:00
Peter Wemm a940444601 MFC: initialize the tss iobase properly
Approved by:  so (cperciva)
2005-04-06 01:44:36 +00:00
Colin Percival a225d5f34e FreeBSD-SA-04:17.procfs:
MFC revision 1.54 of src/sys/fs/procfs/procfs_status.c
MFC revision 1.86 of src/sys/compat/linprocfs/linprocfs.c

Approved by:	so (nectar)
2004-12-01 21:34:43 +00:00
Colin Percival 64f548f29d FreeBSD-SA-04:16.fetch:
MFC revision 1.75 of src/usr.bin/fetch/fetch.c
Bump newvers.sh and document in UPDATING.

Approved by:	so
2004-11-18 12:06:51 +00:00
Jacques Vidrine a437630a8c MFC 1.429: Disallow negative coordinates and sizes in the syscons
CONS_SCRSHOT ioctl.

Approved by:	so
2004-10-04 17:04:25 +00:00
Jacques Vidrine c92cfee45d Correct several vulnerabilities in CVS 1.11.5 (CAN-2004-0414,
CAN-2004-0416, CAN-2004-0417, CAN-2004-0418, CAN-2004-0778 and
others).

Approved by:	so
2004-09-19 22:37:11 +00:00
Colin Percival 9ff423a7d9 FreeBSD-SA-04:13.linux:
MFC revision 1.116 of sys/compat/linux/linux_ioctl.c
Bump newvers.sh and document in UPDATING.

Approved by:	so (des)
2004-06-30 17:34:38 +00:00
cvs2svn 8572a12667 This commit was manufactured by cvs2svn to create branch 'RELENG_5_2'. 2004-06-10 19:05:40 +00:00
Dag-Erling Smørgrav 4c783325c1 Bump patch level and document the change.
Approved by:	so
2004-05-26 06:44:34 +00:00
Dag-Erling Smørgrav 044fa52655 MFS: msync(2) with the MS_INVALIDATE flag should not delete dirty pages.
Approved by:	so
2004-05-25 23:07:55 +00:00
Dag-Erling Smørgrav 3ea2671c8d Merge updated patch from vendor branch (1.1.1.17)
Approved by:	so
2004-05-20 13:18:10 +00:00
Dag-Erling Smørgrav 19a7f1a9de Bump and document patch level.
Approved by:	so
2004-05-19 06:40:56 +00:00
Dag-Erling Smørgrav a2bc8b03d8 Merge parser fix from vendor branch (rev 1.1.1.16)
Approved by:	so
2004-05-19 06:19:57 +00:00
Jacques Vidrine 615a439a9e Correctly validate the transited field in Kerberos tickets.
http://vuxml.freebsd.org/bfb36941-84fa-11d8-a41f-0020ed76ef5a.html

Obtained from:	Heimdal 0.6.1
Approved by:	so
2004-05-05 19:55:46 +00:00
Jacques Vidrine 1a15dd91ff Merge from 4-STABLE client.c 1.2.2.7, modules.c 1.1.1.5.2.4:
Correct some path validation errors in CVS.

Approved by:	so
2004-04-15 15:42:50 +00:00
Jacques Vidrine 299c870ea6 MFC ip6.h 1.11, ip6_output.c 1.79:
Validate IPv6 socket options more carefully.
2004-03-29 14:01:33 +00:00
Jacques Vidrine 6ab589eba7 MFC s3_pkt.c 1.1.1.9:
Correct a denial-of-service vulnerability in OpenSSL (CAN-2004-0079).
2004-03-17 12:18:23 +00:00
Jacques Vidrine 56d478fbea Bump patch level for update of FreeBSD-SA-04:04.tcp fix. 2004-03-16 13:47:33 +00:00
Max Khon 1c464c822e The tcp_reass_qsize increment should occur only after we have
checked for memory allocation failure.  On systems that frequently
have a memory shortage, this could result in an effectively smaller
reassembly queue than was configured.

Approved by:	security-officer
2004-03-15 18:17:10 +00:00
Hideyuki KURASHINA 7cd945dd92 Merge the following from the English version:
1.3       -> 1.3.6.1    relnotes/common/relnotes.ent
  1.7       -> 1.7.4.1    share/sgml/release.dsl
  1.663.2.5 -> 1.663.2.13 relnotes/common/new.sgml

Approved by:	so (nectar)
Refined by:	hrs
2004-03-05 04:11:23 +00:00
Jacques Vidrine 2ccb8fa10b MFC in part tcp_input.c 1.228, tcp_subr.c 1.182, tcp_var.h 1.98:
Limit TCP segment reassembly queue size and use UMA for it.

Submitted by:	andre
2004-03-02 17:24:46 +00:00
Andrey A. Chernov d02dfb867e Back out prev. commit, because not approved. 2004-03-01 16:49:38 +00:00
Andrey A. Chernov c07f4f5d50 MFC important bugfixes from v1.49-1.50 2004-03-01 11:43:50 +00:00
Pawel Jakub Dawidek a28c3ad292 MFC ucred structure leak fix.
Approved by:	re@ (scottl), scottl (mentor)
2004-02-23 15:32:55 +00:00
Scott Long 4d78a30641 Update the BSD family tree for 5.2 and 5.2.1 2004-02-23 05:44:37 +00:00
Scott Long 02a0c16458 Point the pkg tools to the 5.2.1 packages. 2004-02-23 05:35:58 +00:00
Scott Long df2804f090 Change 502001 to 50201. The more I think about it, the more the latter
makes sense.  Sorry for the churn.
2004-02-23 05:34:20 +00:00
Scott Long 7e616136ed Bump __FreeBSD_version to 502001 for the 5.2.1-RELEASE 2004-02-23 05:24:25 +00:00
Scott Long 820b5929c3 Update for 5.2.1-RELEASE 2004-02-23 05:20:41 +00:00
Robert Watson b0b7475582 MFC r127_state.c:1.9 to RELENG_5_2 for inclusion in 5.2.1-RELEASE:
Limit the amount of memory userspace processes can cause the kernel to
  allocate via DRI on r128 devices.

  Obtained from:  Thomas Biege <[email protected]>
  Reviewed by:    scottl

Approved by:	scottl
2004-02-23 05:19:46 +00:00
Scott Long 7b05829164 Update the release makefile for 5.2.1 2004-02-23 05:18:26 +00:00
Scott Long b632a5e7e3 Update the man pages for 5.2.1 2004-02-23 05:13:38 +00:00
Scott Long 3b6214f90e Update for 5.2.1 and note that 5.2.1 is on the 5.2 release branch. 2004-02-23 05:11:00 +00:00
Scott Long 346046f21f Add a hack to allow sysisntall to handle mixing 5.2 vs. 5.2.1 cds.
Submitted by:	murray
Approved by:	re
2004-02-20 17:00:57 +00:00
Jacques Vidrine ff56d0c29d MFC 1.40: Rework jail_attach(2) so that an already jailed process cannot hop to
another jail.

Approved by:	re
2004-02-19 23:26:39 +00:00
Scott Long 1f3668b5ee Reduce AAC_MAX_FIBS a little so that we don't exhaust the queue. This is a
workaround for the lost command problem in RELENG_5_2.

Approved by:	re (implicit)
2004-02-18 06:20:50 +00:00
Bruce A. Mah 826afe135d Version number bumps for the upcoming 5.2.1-RELEASE.
Approved by:	re (implicitly)
2004-02-16 21:21:59 +00:00
Don Lewis 6a3d65c7ce Forced commit to add a notice that the previous commit was ...
Approved by: re (scottl)
2004-02-15 00:16:53 +00:00
Don Lewis 1d2fcd09b3 Partial MFC of revision 1.16.
Change KASSERT() in feed_vchan16() into an explicit test and call to
  panic() so that the buffer overflow just beyond this point is always
  caught, even when the code is not compiled with INVARIANTS.

This will cause a deterministic panic if a particular combination of
sound hardware and client software triggers the buffer overflow in the
vchan code.  This is better than letting the system panic in some
unrelated part of the kernel because of heap corruption.
2004-02-15 00:15:44 +00:00
Marcel Moolenaar adf2588c55 MFC rev 1.351 (no disklabel on ia64).
Approved: re (scottl)
2004-02-14 22:31:04 +00:00
Marcel Moolenaar 1d61c4475f MFC rev 1.14 (uninitialized variable) and 1.15 (non-close of disk
device).

Approved: re (scottl)
2004-02-14 22:29:02 +00:00
Nate Lawson 77270ff3e0 MFC: os_name -> osname fixes the OS override directive for ACPI 2004-02-14 21:46:55 +00:00
Scott Long 621e820c2d MFC: If deferring a command due to lack of card resources, unmap it so that
it will be marked appropriately the next time the queue is run.

Approved by:	re (implicit)
2004-02-11 10:34:24 +00:00
Scott Long d83253a5eb Use 'strip -g' instead of 'strip -x' on the boot floppy modules. Hopefully
this will allows them to work again.

Approved by:	re (implicit)
2004-02-11 10:26:17 +00:00
Scott Long 002de175b5 MFC many more fixes for the ata driver.
Approved by:	re (implicit)
2004-02-11 08:47:22 +00:00
Scott Long b819ed1942 MFC the geom_taskqueue addition so that the pending ATA MFC can use it.
Approved by:	re (implicit)
2004-02-11 08:31:23 +00:00
Jacques Vidrine 97a0e95990 MFC pseudofs_vnops.c 1.43: Fix a panic in pseudofs(9).
Approved by:	re
2004-02-10 21:08:01 +00:00
Jacques Vidrine 410f2d5521 Get ready for 5.2.1-RC2. 2004-02-10 14:13:39 +00:00
Jacques Vidrine 2f81f996d8 MFC vfs_mount.c 1.117: Fix issues related to mount/unmount.
Submitted by:	pjd
Approved by:	re
2004-02-10 14:11:32 +00:00
Bruce A. Mah e0d79e7d14 MFC: SA-04:02.
Approved by:	re (implicitly)
2004-02-06 21:37:54 +00:00
Jacques Vidrine 3aee9b7f32 MFC sysv_shm.c 1.90: Correct a reference counting bug in shmat(2). 2004-02-05 18:01:26 +00:00
Doug Barton 9b9625967a MFC 1.11, the latest from InterNIC.
Approved by:	re (scottl)
2004-02-03 17:12:58 +00:00
Bruce A. Mah 9549d08078 MFC: SA-04:01, devfs(5) path rules, pc98 libdisk bugfix.
Approved by:	re (implicitly)
2004-02-03 06:14:32 +00:00
Scott Long d0cead40a3 Run 'strip -x' on the kernel modules on the mfsroot floppy to reclaim some
space.  This appears to be safe for what we need here.  This is needed now
because the slight addition to the readme files has caused the mfsroot
floppy to overflow again.

Approved by:	re (implicit)
2004-01-31 16:30:45 +00:00
Scott Long 9b32ccbcbf Shift into RC mode for 5.2.1
Approved by:	re (implicit)
2004-01-30 16:24:12 +00:00
Jacques Vidrine 60725be8a2 5.2-RELEASE-p1 is a security branch release to address an issue in
mksnap_ffs(8).  Because release engineering for 5.2.1-RELEASE is
currently in process, 5.2-RELEASE-p1 also includes several other bug
fixes which are not security related.  The additional fixes are
documented in UPDATING and in the release notes.

Approved by:	re
2004-01-29 22:54:31 +00:00
Colin Percival 2256e90431 MFC rev 1.9-1.10: Allow path rules to work on directories.
Approved by:	rwatson (mentor), re (scottl)
2004-01-29 19:32:43 +00:00
Colin Percival 0995c3896a MFC 1.3: If we're going to unhide fd/*, we'd better unhide fd as well.
Approved by:	rwatson (mentor), re (scottl)
2004-01-29 19:28:57 +00:00
Yoshihiro Takahashi 7ec68c7a70 MFC: revision 1.25 (Fixed pc98 partition type.)
Approved by:	re (scottl)
2004-01-28 04:12:20 +00:00
Dag-Erling Smørgrav 7f8cc3a8e5 MFC (1.6): preserve existing options on the mountpoint we're snapshotting. 2004-01-27 19:33:16 +00:00
Bruce A. Mah a71f8d7614 MFC: IPsec fixes, ata(4) fixes.
Approved by:	re (implicitly)
2004-01-27 16:24:21 +00:00
Hajimu UMEMOTO feb160a56f MFC 1.65: avoid duplicate free.
Approved by:	re (scott)
2004-01-27 16:06:22 +00:00
Hajimu UMEMOTO 31ed7881ff MFC 1.64: invalidate secpolicy pcb cache on key_timehandler.
Approved by:	re (scott)
2004-01-27 16:04:52 +00:00
Hajimu UMEMOTO 0db9ecbc9a MFC 1.63: add missing key_freesp()s.
Approved by:	re (scott)
2004-01-27 16:03:30 +00:00
Hajimu UMEMOTO 0b783ecd8b MFC 1.62: don't touch after free.
Approved by:	re (scott)
2004-01-27 16:01:52 +00:00
Hajimu UMEMOTO 9246cdb43e MFC 1.31: fix potential 'cannot-happen' memory leak
Approved by:	re (scott)
2004-01-27 15:59:26 +00:00
Hajimu UMEMOTO 0e55c4f224 MFC 1.47: call ipsec_pcbconn()/ipsec_pcbdisconn() from in6_pcbconnect().
Approved by:	re (scott)
2004-01-27 15:57:16 +00:00
Hajimu UMEMOTO ec5e6a3a56 MFC 1.136: do not deref freed pointer
Approved by:	re (scottl)
2004-01-27 15:54:05 +00:00
Scott Long fd667ad630 Bring the ata man page up to HEAD to stay in sync with the ata driver. 2004-01-27 15:21:30 +00:00
Scott Long 84067e9544 Remove local changes to ata that accidentally crept in. 2004-01-27 15:11:35 +00:00
Scott Long 6599de8adc Don peril-senstive goggles and update the ata driver to HEAD.
Approved by:	re
2004-01-27 05:53:19 +00:00
Bruce A. Mah 6f7b4016c0 MFC: Make CVS update release note match reality.
Submitted by:	nectar
Approved by:	re (implicitly)
2004-01-27 00:53:22 +00:00
Bruce A. Mah ad0c026ca4 MFC: PFIL_HOOKS now enabled in GENERIC.
Move KUser note from ports/packages section to releng section so that
it sits next to other KDE-related text.

Approved by:	re
2004-01-26 20:03:53 +00:00
Jacques Vidrine 2a342ab5f2 MFC: Add PFIL_HOOKS to the GENERIC kernel configuration.
Requested by:	re
2004-01-26 19:42:13 +00:00
Bruce A. Mah c7203ee0d7 Bring the 5.2.1 release notes up to date with the state of the
RELENG_5_2 branch thus far.

MFC:  cdboot BIOS bug workaround, dc(4) on sparc64 update, sk(4)
multicast fix, GEOM I/O hang fix, NFSv4 panic fix, NSS bugfix, CVS
security fixes.

New release note:  kdeadmin3 update.

Approved by:	re (implicitly)
2004-01-26 16:52:54 +00:00
Scott Long 08b79a8d0c Merge rev 1.46 of geom_event.c. This prevents deleted events from getting
lost and hanging I/O.

Approved by:	re
2004-01-26 05:18:35 +00:00
Scott Long a20338c1ae Bring rpcclnt.c up to HEAD in order to fix several potential panics when
mixing NFS protocols.

Approved by:	re
2004-01-26 04:38:17 +00:00
Jacques Vidrine 6aec46cdbd MFC 1.1.1.14: Do not allow pserver to be run as root. 2004-01-26 00:08:38 +00:00
Jacques Vidrine fa7de625b8 MFC 1.1.1.9: Reject malformed module requests.
Approved by:	re
2004-01-26 00:07:36 +00:00
Bruce A. Mah 1362efe4e9 Add a few sentences to the readme and release notes describing this
point release.

Approved by:	re
2004-01-25 18:50:50 +00:00
Bruce A. Mah 79d0299ece Fix up some release notes glitches that didn't make it for
5.2-RELEASE: Fix a repeated word [1], fix GCC-related typo (was in
errata) [2], add missing note on TCP mss limiting (was in errata).

Submitted by:	jens [1], gerald [2]
Approved by:	re
2004-01-25 18:36:00 +00:00
Bruce A. Mah 46a7e7465d Infrastructure commits for the release documentation for a probable
5.2.1-RELEASE.  The main changes will be to the release notes, which
will be based on the 5.2-RELEASE notes with the 5.2 -> 5.2.1 changes
added and emphasized.

Approved by:	re
2004-01-25 18:28:11 +00:00
Scott Long 4e826732fd Bring the NSS files up to HEAD to fix the problem with 3rd party modules
accessing large groups.

Approved by:	re
2004-01-25 06:00:42 +00:00
Scott Long 4beb8d28f8 MFC the if_dc fix for sparc64 Davicom cards that store thier MAC in
OFW instead in SEEPROM.

Approved by:	re
2004-01-25 05:23:21 +00:00
Scott Long ba82adac64 Bring if_sk.c to HEAD to fix the multicast problem with newer chips.
Approved by: re
2004-01-25 05:06:48 +00:00
John Baldwin 8beaf2008c MFC: Save %cx around calls to the BIOS to read data to workaround bugs in
certain BIOSs when booting from a USB CD-ROM.  Also, fix the twiddle to
actually twiddle.

Approved by:	re
2004-01-25 01:20:36 +00:00
Hiroki Sato f7a0e21612 MFC: merge Japanese translation of 5.2R release docs into RELENG_5_2.
Approved by:	re (bmah)
2004-01-17 03:34:33 +00:00
Hiroki Sato 8715aa0832 MFC: merge Japanese translation of 5.2R release docs into RELENG_5_2.
Approved by:	re (bmah)
2004-01-17 03:24:56 +00:00
Scott Long 7dbb88eb2e Move up to 5.2-RELEASE! 2004-01-10 05:53:28 +00:00
Scott Long 481a5ea35f MFC rev 1.131:
Enable building mount_nfs4.

Submitted by:	alfred
2004-01-10 04:11:22 +00:00
Scott Long bb066eb657 MFC rev 1.9:
Disable the APIC when selection the 'Safe Boot' option.

Approved by: rwatson
2004-01-10 03:36:14 +00:00
David Malone ad52416410 MFC: Make ip6fw reset work for TCP packets with SYN set.
Approved by:	re, sam, ume
2004-01-09 23:54:24 +00:00
Don Lewis e715b78ac0 MFC 1.138 - Check for transmit status and free the mbuf chain when
processing the last transmit descriptor for the frame
            instead of the first descriptor.  This eliminates the
            bug that caused the driver to report spurious collisions
            and output errors that was introduced when the driver
            was changed to look at the first transmit descriptor
            when it was converted to use busdma (rev 1.115).

Approved by:	re (scottl)
2004-01-09 21:13:56 +00:00
Bruce A. Mah 982ed5af91 The change that set the ip_id to 0 on DF packets was reverted due to
compatibility issues, so remove its release note.

While here, bump copyright date for 2004 changes.

Approved by:	re (implicitly)
2004-01-09 17:08:32 +00:00
Bruce A. Mah dd634cb516 Delete a release note that doesn't apply anymore: We're installing
the full KDE and GNOME package sets, not the "Lite" versions.

Approved by:	re (implicitly)
2004-01-09 17:01:48 +00:00
Andre Oppermann 9b9509b1a5 MFC: Limiters and sanity checks for TCP MSS resource exhaustion attacks.
The net.inet.tcp.minmssoverload is set to zero and thus connection drop
is disabled by default.

Approved by:	re (scottl)
2004-01-09 16:47:11 +00:00
Andre Oppermann fd84825681 MFC rev 1.20: Reduce TCP_MINMSS default to 216.
Approved by:	re (scottl, implicit)
2004-01-09 14:29:52 +00:00
Andre Oppermann 63faf15a9e MFC: Limiters and sanity checks for TCP MSS resource exhaustion attacks.
The net.inet.tcp.minmssoverload is set to zero and thus connection drop
is disabled by default.

Approved by:	re (scottl)
2004-01-09 12:32:36 +00:00
Andre Oppermann 78779d572b MFC rev 1.173: If path mtu discovery is enabled set the DF bit in all
cases we send packets on a tcp connection.

PR:		kern/60889
Approved by:	re (scottl)
2004-01-09 12:23:58 +00:00
Andre Oppermann 222a2708bb MFC rev 1.204: Do not set the ip_id to zero when DF is set on packet.
Approved by:	re (scottl)
2004-01-09 12:18:17 +00:00
Sam Leffler 598a20cc0e MFC 1.92: remove extraneous unlock that can lead to a panic
Approved by:	re (scottl)
2004-01-08 16:31:33 +00:00
Warner Losh 8868d625ea MFC: Copyright 2004
approved by: re@ (scottl)
2004-01-08 04:53:29 +00:00
Warner Losh c83451d3a7 MFC: Update the copyright date here to
Approved by: re@ (scottl)
2004-01-08 04:51:06 +00:00
Joerg Wunsch 92c839c9df Merge critical bugfix (panic due to NULL pointer deref) from rev 1.30.
Approved by:	re
2004-01-07 16:46:06 +00:00
Scott Long 6ca3b740c3 Revert rev 1.51. There turns out to be enough room on the CD for the
full Gnome and KDE packages.
2004-01-07 07:44:19 +00:00
Scott Long baa21206e0 Revert rev 1.219. We will install the full gnome and kde packages. 2004-01-07 07:42:15 +00:00
Doug Barton 5ecf0a2a4d Commit the fix from 1.49 which prevents false positives in the
-p (pre-world) case

Approved by:	re (scottl)
2004-01-06 18:06:38 +00:00
Martin Blapp f22d7eed1c MFC: Rev. 1.8
The reset_type should not be 0x80, it should be set to zero.
0x80 can cause the command to be rejected as invalid. This bug
exists also in the Linux IPS ffdc code.

Submitted by:	David Jeffery (Adaptec)
Approved by:	scottl (re)
2004-01-06 15:52:23 +00:00
Doug Barton 21b71a3a96 MFC 1.48, which contains two small cleanups and the
"stale /etc/rc.d file" checker.

PR:		bin/60246
Approved by:	re (scottl)
2004-01-03 19:16:14 +00:00
Guido van Rooij f58a5b73fc MFC: 1.17
if_name and if_unit renaming to if_xname should be dealth with in
  ipmon as well.

Approved by:	re
2004-01-03 14:12:11 +00:00
Bruce A. Mah 3cd4e46ec7 MFC: Catch up with reality with respect to the location of 4.8, 4.9,
5.0, 5.1, 5.2, and CURRENT packages.

	main.c	1.54->1.55

Approved by:	re (scottl)
2004-01-02 06:12:05 +00:00
Bruce A. Mah 17f9ac2b51 Version number bumps for the upcoming 5.2-RELEASE.
Approved by:	re
2004-01-01 21:55:07 +00:00
David Malone ca8cf52b9b Plug file descriptor leak, as discussed on -current.
Approved by:	re (scottl)
2003-12-30 20:13:19 +00:00
Poul-Henning Kamp df331583f7 MFC:
per provider withering (for atapi-cd)
	G_PF_ORPHAN flag & check. (for atapi-cd)
	mtx_init NULL/MTX_DEF confusion.

Approved by:	re@
2003-12-30 12:00:40 +00:00
Poul-Henning Kamp b3f690998d MFC: Improvements to if_sis driver.
Don't spend interrupt time stopping already stopped interfaces.
  Fix short-cable handling code.

Approved by:	re@
2003-12-30 10:47:22 +00:00
John Baldwin a4f660fe50 MFC: Fix acpi_MatchHid() to check compatability IDs.
Approved by:	re (scottl)
2003-12-29 15:48:16 +00:00
Ruslan Ermilov c1e66e7e3f MFC: 1.24: Hopefully fix the upgrade path from old 4.x and 5.x systems.
Approved by:	re (jhb)
2003-12-24 17:31:53 +00:00
Sam Leffler 04df9af671 MFC 1.97: fix double mutex initialization when statically configured
Approved by:	re (scottl)
2003-12-23 19:21:16 +00:00
Maxim Konovalov 793916daeb MFC rev. 1.52: IN_MULTICAST wants an address in host byte order.
Approved by:	re (scottl)
2003-12-23 12:25:56 +00:00
Scott Long f608fa17ae MFC rev 1.33: Move the em and vx drivers back into the kernel. 2003-12-22 15:20:45 +00:00
SUZUKI Shinsuke 066a685df4 MFC Rev 1.71
fixed an IPv6 path MTU discovery failure owing to a lack of initialization.

approved by: re(scottl)
2003-12-22 03:04:00 +00:00
Scott Long 71cd182013 MFC Rev 1.350:
Teach the Fixit environment about dynamic root.
2003-12-21 18:00:45 +00:00
Ken Smith 61ce60d1f9 - Add FTP site in Turkey.
Approved by:	murray (re@)
2003-12-21 06:11:51 +00:00
Bruce A. Mah 448ad2be0e New release notes: fatm(4) [1], hfa update [1], initgroups(3) change
and implications for users in lots o' groups.

Approved by:	re (scottl)
Submitted by:	harti [1]
2003-12-20 17:58:57 +00:00
John Baldwin b86ef4fe5d InstaMFC: Mount the mfsroot read/write during installs.
Approved by:	re (scottl)
2003-12-20 16:35:51 +00:00
Scott Long 9bef3237d9 MFC: Don't force-unmount devfs during install
Approved by: re
2003-12-19 11:26:44 +00:00
Nate Lawson 3499ec30a3 MFC: Add support for _CID package types and use dynamic storage for
all of our devinfo structs.

Revisions:	acpi.c:1.110; acpi_pcib.c:1.35,1.36; acpi_pci_link.c:1.11

Approved by:	re (scottl, in a new record time)
2003-12-19 00:03:02 +00:00
John Baldwin ff8a3c7aa0 MFC: Sync ata driver with head.
- Various fixes for SiI3112A.
- Support for the SiS 661 chipset.
- Fix register timings for AMD/VIA/nVidia chipsets.

Approved by:	scottl (re)
2003-12-18 21:39:38 +00:00
John Baldwin 946bc5e31c MFC: Handle empty channels in earlier fix for missing slaves.
Approved by:	re (scottl)
2003-12-18 21:31:14 +00:00
Robert Watson 7a8df2a679 Merge dist.c:1.228 from HEAD to RELENG_5_2:
Install 100dpi fonts by default when installing X11: fun as using 75dpi
  fonts on a 100dpi display is, the jaggies just aren't worth it.  DPMI
  auto-configures higher DPIs on many modern displays now.

Approved by:	re (jhb)
2003-12-18 18:40:41 +00:00
Garance A Drosehn 85b084f74f MFC 1.398: Fix a problem where 'make installworld' can fail and
leave the system in a messy state when upgrading from a system
which has no /libexec to a system which builds a DYNAMICROOT.

Approved by:	re (scottl)
2003-12-18 18:22:21 +00:00
Jeff Roberson d782b48b33 - MFC 1.475, return EBUSY if NOWAIT was passed to vget() and the XLOCK was
held.

Approved by:    re (scottl)
2003-12-18 16:22:16 +00:00
Jeff Roberson 2c35c78a5f - MFC 1.474, properly cleanup VCHR after forced unmount.
Approved by:	re (scottl)
2003-12-18 16:09:26 +00:00
David E. O'Brien 9f89821fc9 Define __LP64__ when producing 64-bit code.
Approved by:	re(jhb)
2003-12-18 04:33:34 +00:00
Peter Wemm 9869849933 MFC: add sys/_null.h and change the definition of NULL to a long on ia64
and amd64.  Ensure that this is not accidently activated on any platforms
other than these two since its quite late in the release cycle and it is
not worth the risk of disturbing to the established platforms.

Approved by:  re (scottl, jhb)
2003-12-18 00:59:51 +00:00
Poul-Henning Kamp e479892a32 MFC: make preloaded filesystems work with md(4) again.
Approved by:	re@(scottl)
2003-12-17 19:48:00 +00:00
Tim J. Robbins 48455098b0 MFC: Make msdosfs long filenames matching case insensitive again.
Approved by:	re (scottl)
2003-12-17 11:35:11 +00:00
Tim J. Robbins befc6801c4 MFC rev. 1.33: Don't sign-extend characters in file names.
Approved by:	re (scottl)
2003-12-17 09:35:44 +00:00
Robert Watson ec3ea865f0 Merge revision 1.2 of securelevel.hlp to RELENG_5_2:
Re-linewrap help file on securelevels in sysinstall: sysinstall is
  mostly used on 80x25 displays, and the actual window is about ten
  characters narrower than that, resulting in the need for horizontal
  scrolling.  No functional change.

Approved by:	re (scottl)
2003-12-17 05:19:16 +00:00
Poul-Henning Kamp 446539c4d1 Don't free(9) modified pointer.
Approved by:	re@
2003-12-16 20:27:07 +00:00
John Baldwin b550e2dffe MFC: Add note about acpi module being re-enabled.
Approved by:	re (rwatson)
2003-12-16 16:19:52 +00:00
cvs2svn f4d26baa51 This commit was manufactured by cvs2svn to create branch 'RELENG_5_2'. 2003-12-15 10:25:19 +00:00
Peter Wemm e296f29988 MFC: bandaid for R_X86_64_PC32 relocation type. Do not try to fit a 64
bit peg in a 32 bit hole.

Approved by:  re (scottl)
2003-12-14 00:45:40 +00:00
Peter Wemm d40dbb0c7b MFC: 1.13: use the correct symbol for declaring the sysvec table sizes
Approved by:  re (jhb, scottl)
2003-12-13 22:20:03 +00:00
Peter Wemm ff7c376de8 Regen
Approved by: re (scottl, jhb)
2003-12-13 22:19:06 +00:00
Peter Wemm 79ea91c806 MFC: 1.27-1.28: sync up syscalls list 2003-12-13 22:18:27 +00:00
Bruce A. Mah 66c21b6a13 Fix some random typos. No effect on any translations; these are all
English language bogons.

Submitted by:	hrs, harti
Approved by:	re (implicitly)
Pointy hat to:	bmah
2003-12-13 08:24:04 +00:00
Bruce A. Mah 32e46d4024 Version number bumps for 5.2-RELEASE release documentation.
Approved by:	re (implicitly)
2003-12-12 05:46:32 +00:00
Don Lewis f855b04f89 MFC 1.226 - Set fs_ronly to the correct value in ffs_reload() when
reloading the file system super block after fsck has
            repaired the file system.

Approved by:	re (scottl + jhb)
2003-12-12 02:23:22 +00:00
Alexander Kabaev 25fa72ec65 MFC revision 1.175
Addendum to revision 1.174: In the case where vm_pager_allocate() is called
to create a vnode-backed object, the vnode lock must be held by the caller.

Approved by:	re (scottl)
2003-12-11 20:30:15 +00:00
Warner Losh 5fb427aebf Up the timeout on a command from 500ms to 5s unconditionally. This
will up the failure time from about 1s to about 7s in the worst case
that I can think of.  Other fixes have brought that number down from
30 minutes, so I don't feel too bad about it.  Some older versions of
the Prism cards have issues that make them unable to respond in 500ms
for some commands.  Current has a more extensive fix that only
penalizes the old firmware, but this is a more conservative change
more appropriate to a frozen branch.

Suggested/Submitted by: iedowse
Approved by: re (scottl)
2003-12-11 20:21:20 +00:00
Alexander Kabaev 364e6ad2a4 MFC rev. 1.6: Install two new include files for SSE2 and Prescott
intrinsics.
2003-12-11 20:16:01 +00:00
Tim J. Robbins c38e3aa7a9 MFC rev. 1.34: Set __mbrtowc and __wcrtomb correctly when changing to
the C/POSIX locale. Save __mbrtowc and __wcrtomb and restore them when
changing back to the cached locale.

Approved by:	re (scottl)
2003-12-11 20:06:22 +00:00
John Baldwin 60749595bc MFC: Replace fix for empty turnstile race with a more general fix for the
more general race of a thread that was already woken up but still pending.
Adjust assertion for TDF_TSNOBLOCK case to allow for a thread to be on the
run queue as well as currently running.

Approved by:	re (scottl)
2003-12-11 20:01:52 +00:00
John Baldwin 2c2b3b6b7e MFC: Add a note to document MPTABLE_FORCE_HTT.
Approved by:	re (scottl)
2003-12-11 19:56:40 +00:00
Bruce M Simpson e6dc1d7d67 Nursemaid: Fix compilation.
Sponsored by:	Weyland-Yutani Corporation
2003-12-10 15:02:02 +00:00
Scott Long 4b53300c0c Don't build a kernel.debug for the release. 2003-12-07 23:52:54 +00:00
Peter Wemm 8dcfd23ac5 MFC: 1.85: fix the runq selection when load balancing runs on machines with
64 bit runq status bit fields.

Approved by:  re (scottl)
2003-12-07 18:21:53 +00:00
Daniel Eischen 918783a66c MFC: Don't call em_stop() when the watchdog expires. This prevents
a panic caused by a mutex assertion.

Approved by:	re@(scottl)
2003-12-07 16:53:50 +00:00
Bruce A. Mah cfc1c85d6f Version number bump for 5.2-RC.
Approved by:	re (implicitly)
2003-12-07 16:18:48 +00:00
Bruce A. Mah c42206d987 Put generated RELNOTESng snapshot in the right place for 5.2.
Approved by:	re (implicitly)
2003-12-07 16:18:10 +00:00
Bruce A. Mah 9844500419 Modified release note: a.out toolchain removal applies to pc98 as well.
Approved by:	re (implicitly)
Submitted by:	nyan
2003-12-07 16:17:01 +00:00
Scott Long 54203f5e47 Update man pages to 5.2 2003-12-07 04:32:50 +00:00
Scott Long ee12e83ecb Point 'make update' at RELENG_5_2 2003-12-07 04:29:35 +00:00
Scott Long dfd7377f55 Update UPDATING for 5.2 2003-12-07 04:25:21 +00:00
Scott Long 86536f3f9a Remove malloc debugging for the release. 2003-12-07 04:12:46 +00:00
Scott Long 303048382c Disable WITNESS, INVARIANTS, and DDB for our Tier-1 platforms for the release 2003-12-07 04:10:47 +00:00
Scott Long 52eeaa89e0 Fix up sh(1) for the release. 2003-12-07 04:03:59 +00:00
Scott Long 3cfe1020d8 Switch to a label that is appropriate for the release.
Submitted by:	obrien
2003-12-07 04:02:46 +00:00
Scott Long ac0e1c8df7 RELENG_5_2 is at 502000 2003-12-07 03:59:11 +00:00
Scott Long 94d09e13f6 RELENG_5_2 is at 5.2-RC now 2003-12-07 03:57:41 +00:00
cvs2svn a348451bd8 This commit was manufactured by cvs2svn to create branch 'RELENG_5_2'. 2003-12-07 03:02:28 +00:00
792 changed files with 5483 additions and 243363 deletions

No files matched your search

+29
View File
@@ -1,6 +1,35 @@
# $FreeBSD$
# @(#)COPYRIGHT 8.2 (Berkeley) 3/21/94
The compilation of software known as FreeBSD is distributed under the
following terms:
Copyright (C) 1992-2004 The FreeBSD Project. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
The 4.4BSD and 4.4BSD-Lite software is distributed under the following
terms:
All of the documentation and software included in the 4.4BSD and 4.4BSD-Lite
Releases is copyrighted by The Regents of the University of California.
+8 -14
View File
@@ -46,19 +46,16 @@ SUBDIR+= share/info
.if exists(${.CURDIR}/include)
SUBDIR+= include
.endif
# We must do lib and libexec before bin, because if installworld
# installs a new /bin/sh, the 'make' command will *immediately*
# use that new version. And the new (dynamically-linked) /bin/sh
# will expect to find appropriate libraries in /lib and /libexec.
.if exists(${.CURDIR}/lib)
SUBDIR+= lib
.endif
# When upgrading to a dynamically linked root, install the runtime
# linker early into its new location before make(1) has a chance
# to run the dynamically linked /bin/sh.
.if !defined(NO_DYNAMICROOT) && !defined(NOPIC) && \
(!defined(TARGET_ARCH) || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
!defined(DISTDIR) && \
(!defined(DESTDIR) || empty(DESTDIR) || ${DESTDIR} == "/") && \
!exists(/libexec/ld-elf.so.1)
SUBDIR+= libexec/rtld-elf
.if exists(${.CURDIR}/libexec)
SUBDIR+= libexec
.endif
.if exists(${.CURDIR}/bin)
@@ -74,9 +71,6 @@ SUBDIR+= gnu
!defined(NOCRYPT) && !defined(NO_OPENSSL) && !defined(NO_KERBEROS)
SUBDIR+= kerberos5
.endif
.if exists(${.CURDIR}/libexec)
SUBDIR+= libexec
.endif
.if exists(${.CURDIR}/rescue) && !defined(NO_RESCUE)
SUBDIR+= rescue
.endif
@@ -591,7 +585,7 @@ update:
@echo "--------------------------------------------------------------"
@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${CVS} -R -q update -A -P -d
cd ${.CURDIR}; ${CVS} -R -q update -rRELENG_5_2 -P -d
.endif
#
+146 -13
View File
@@ -1,21 +1,142 @@
Updating Information for FreeBSD current users
Updating Information for FreeBSD 5.2.1 users
This file is maintained and copyrighted by M. Warner Losh
<[email protected]>. See end of file for further details. For commonly
done items, please see the COMMON ITEMS: section later in the file.
NOTE TO PEOPLE WHO THINK THAT FreeBSD 5.x IS SLOW:
FreeBSD 5.x has many debugging features turned on, in
both the kernel and userland. These features attempt to detect
incorrect use of system primitives, and encourage loud failure
through extra sanity checking and fail stop semantics. They
also substantially impact system performance. If you want to
do performance measurement, benchmarking, and optimization,
you'll want to turn them off. This includes various WITNESS-
related kernel options, INVARIANTS, malloc debugging flags
in userland, and various verbose features in the kernel. Many
developers choose to disable these features on build machines
to maximize performance.
This is for the 5.2 release branch. FreeBSD 5.2.1 is part of the 5.2
release branch and has no branch of its own. All entries since 5.0 are an
itemized list of commits to this branch, numbered from the beginning.
The security advisories related to various patches contain information
on how to build/install a minimal set of binaries and start/stop a
minimal number of processes, if possible, for that patch. For those
updates that don't have an advisory, or to be safe, you can do a full
build and install as described in the COMMON ITEMS section.
20050406: p14 FreeBSD-SA-05:03.amd64
Correctly initialize the I/O permission bitmap on amd64.
20041201: p13 FreeBSD-SA-04:17.procfs
Fix a tainted pointer dereference in procfs(5) and linprocfs(5)
which could allow a local attacker to panic a system and/or read
from kernel memory.
20041118: p12 FreeBSD-SA-04:16.fetch
Correct a buffer overflow in fetch(1) which could allow a
mallicious server to execute arbitrary code on the client.
20041003: p11 FreeBSD-SA-04:15.syscons
Correct a kernel memory disclosure vulnerability in syscons(4).
20040919: p10 FreeBSD-SA-04:14.cvs
Correct several vulnerabilities in CVS (CAN-2004-0414,
CAN-2004-0416, CAN-2004-0417, CAN-2004-0418, CAN-2004-0778).
20040630: p9 FreeBSD-SA-04:13.linux
Correct an input validation error in the linux binary
compatibility code.
20040526: p8 FreeBSD-SA-04:11.msync
Fix a bug in msync(2) which could cause it to discard dirty
pages.
NOTE: In some cases involving NFS, the incorrect behaviour may
actually be preferrable. Setting the vm.old_msync sysctl
variable to 1 will revert msync(2) to its old behaviour.
20040519: p7 FreeBSD-SA-04:10.cvs
Correct a heap overflow in cvs's pserver protocol parser.
20040505: p6 FreeBSD-SA-04:08.heimdal
Correctly validate the transited field in Kerberos tickets.
20040415: p5 FreeBSD-SA-04:07.cvs
Correct some path validation errors in CVS.
20040329: p4 FreeBSD-SA-04:06.ipv6
Correct an input validation error involving setsockopt and
IPv6 sockets.
20040317: p3 FreeBSD-SA-04:05.openssl
Correct a denial-of-service vulnerability in OpenSSL.
20040316: p2
Improvement of FreeBSD-SA-04:04.tcp fix.
20040302: p1 FreeBSD-SA-04:04.tcp
Limit TCP segment reassembly queue size.
20040222:
FreeBSD 5.2.1 RELEASE
20040210:
Fixed bugs in vfs_mount(9) that could allow jailed processes
to mount or unmount file systems outside of the jail and
in some cases allow a normal user to unmount a file system
when usermounts have been changed from enabled to disabled.
Fix a panic in pseudofs(9).
20040205: p2 FreeBSD-SA-04:02.shmat
Correct a reference counting bug in shmat(2).
20040127: p1 FreeBSD-SA-04:01.mksnap_ffs
Fixed mksnap_ffs to preserve existing file system flags.
NOTE WELL:
Due to release engineering in progress, 5.2-RELEASE-p1 also
includes numerous other critical bug fixes, most of which
are not security related.
- (i386) `cdboot' now works around a BIOS problem observed on
some systems when booting from USB CDROM drives.
- (sparc64) The dc(4) driver now supports sparc64 Davicom
cards that store their MAC address in OpenFirmware.
- Several bugs related to multicast and promiscuous mode
handling in the sk(4) driver have been fixed.
- A bug in GEOM(4) that could result in I/O hangs in some
rare cases has been fixed.
- A panic in the NFSv4 client has been fixed; this occurred
when attempting operations against an NFSv3/NFSv2-only
server.
- A bugfix has been applied to NSS support, which fixes
problems when using third-party NSS modules (such as
`net/nss_ldap') and groups with large membership lists.
- Security improvements from CVS 1.11.10 and 1.11.11 have
been backported. Specifically, certain malformed module
requests are now rejected, and when using `cvs pserver'
mode, attempts to authenticate as `root' are rejected and
recorded via syslog(3).
- The `PFIL_HOOKS' option is now enabled by default in the
GENERIC kernel. The most notable effect of this change is
to make IPFilter work correctly when loaded as a kernel
module.
- Some bugs in the IPsec implementation from the KAME Project
have been fixed. These bugs were related to freeing memory
objects before all references to them were removed, and
could cause erratic behavior or kernel panics after flushing
the Security Policy Database (SPD).
- A number of bugs in the ata(4) driver have been fixed. Most
notably, master/slave device detection should work better,
and some problems with timeouts should be resolved.
- (pc98) The partition type used for new partitions on the pc98
platform was corrected.
- Allow devfs path rules to work on directories.
20031206:
FreeBSD 5.2 branched
20031112:
The statfs structure has been updated with 64-bit fields to
@@ -43,6 +164,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 5.x IS SLOW:
new kernel otherwise on a system with new binaries and an old
kernel.
20031203:
The ACPI module has been reactivated. It is no longer required
to compile ACPI support into kernels statically.
20031112:
Some netgraph string length constants have been changed. This
change requires the netgraph kernel modules and all netgraph
@@ -50,6 +175,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 5.x IS SLOW:
netgraph to boot need to make sure to have world and kernel in
sync before rebooting.
20031111:
Hyperthreading logical CPU's are no longer probed by default
when using the MP Table. If ACPI is being used, then logical
CPUs will be probed if hyperthreading is enabled in the BIOS.
If ACPI is not being used and hyperthreading is enabled in the
BIOS, logical CPUs can be enabled by building a custom kernel
with the option MPTABLE_FORCE_HTT enabled.
20031103:
The i386 APIC_IO kernel option has been replaced by
'device apic'. The ACPI module has also been temporarily
-161
View File
@@ -1,161 +0,0 @@
/* config.h. Generated automatically by configure. */
/*
* config.h -- configure various defines for tcsh
*
* All source files should #include this FIRST.
*
* Edit this to match your system type.
*/
/* $FreeBSD$ */
#ifndef _h_config
#define _h_config
/****************** System dependant compilation flags ****************/
/*
* POSIX This system supports IEEE Std 1003.1-1988 (POSIX).
*/
#define POSIX
/*
* POSIXJOBS This system supports the optional IEEE Std 1003.1-1988 (POSIX)
* job control facilities.
*/
#define POSIXJOBS
/*
* POSIXSIGS Use the POSIX signal facilities to emulate BSD signals.
*/
/* #undef POSIXSIGS */
/*
* VFORK This machine has a vfork().
* It used to be that for job control to work, this define
* was mandatory. This is not the case any more.
* If you think you still need it, but you don't have vfork,
* define this anyway and then do #define vfork fork.
* I do this anyway on a Sun because of yellow pages brain damage,
* [should not be needed under 4.1]
* and on the iris4d cause SGI's fork is sufficiently "virtual"
* that vfork isn't necessary. (Besides, SGI's vfork is weird).
* Note that some machines eg. rs6000 have a vfork, but not
* with the berkeley semantics, so we cannot use it there either.
*/
#define VFORK
/*
* BSDJOBS You have BSD-style job control (both process groups and
* a tty that deals correctly
*/
#define BSDJOBS
/*
* BSDSIGS You have 4.2-style signals, rather than USG style.
* Note: POSIX systems should not define this unless they
* have sigvec() and friends (ie: 4.3BSD-RENO, HP-UX).
*/
#define BSDSIGS
/*
* BSDTIMES You have BSD-style process time stuff (like rusage)
* This may or may not be true. For example, Apple Unix
* (OREO) has BSDJOBS and BSDSIGS but not BSDTIMES.
*/
#define BSDTIMES
/*
* BSDLIMIT You have BSD-style resource limit stuff (getrlimit/setrlimit)
*/
#define BSDLIMIT
/*
* BSDNICE Your system uses setpriority() instead of nice, to
* change a processes scheduling priority
*/
#define BSDNICE
/*
* TERMIO You have struct termio instead of struct sgttyb.
* This is usually the case for SYSV systems, where
* BSD uses sgttyb. POSIX systems should define this
* anyway, even though they use struct termios.
*/
#define TERMIO
/*
* SYSVREL Your machine is SYSV based (HPUX, A/UX)
* NOTE: don't do this if you are on a Pyramid -- tcsh is
* built in a BSD universe.
* Set SYSVREL to 1, 2, 3, or 4, depending the version of System V
* you are running. Or set it to 0 if you are not SYSV based
*/
#define SYSVREL 0
/*
* YPBUGS Work around Sun YP bugs that cause expansion of ~username
* to send command output to /dev/null
*/
/* #undef YPBUGS */
/*
* SIGVOID Define this if your signal handlers return void. On older
* systems, signal returns int, but on newer ones, it returns void.
*/
#define SIGVOID
/*
* HAVEDUP2 Define this if your system supports dup2().
*/
#define HAVEDUP2
/*
* UTHOST Does the utmp file have a host field?
*/
#define UTHOST
/*
* DIRENT Your system has <dirent.h> instead of <sys/dir.h>
*/
#define DIRENT
/****************** local defines *********************/
/****************** configurable hacks ****************/
#include <stdlib.h>
/* have been moved to config_f.h */
#include "config_f.h"
#if defined(__FreeBSD__)
#define NLS_BUGS
/* we want to use the system malloc when we install as /bin/csh */
#define SYSMALLOC
#define BSD_STYLE_COLORLS
#endif
#if defined(__bsdi__)
/*
* _PATH_TCSHELL if you've change the installation location (vix)
*/
# if _BSDI_VERSION >= 199701
# define _PATH_TCSHELL "/bin/tcsh"
/* # undef SYSMALLOC */
# define SYSMALLOC
# else
# define _PATH_TCSHELL "/usr/contrib/bin/tcsh"
# endif
# undef NLS
# undef NLS_CATALOGS
#elif defined(__APPLE__)
# define SYSMALLOC
#else
# define NLS_CATALOGS
#endif
#define KANJI
#define DSPMBYTE
#endif /* _h_config */
/* config.h.in. Generated automatically from configure.in by autoheader. */
+1
View File
@@ -9,6 +9,7 @@ SHSRCS= alias.c arith.y arith_lex.l cd.c echo.c error.c eval.c exec.c expand.c \
GENSRCS= builtins.c init.c nodes.c syntax.c
GENHDRS= builtins.h nodes.h syntax.h token.h y.tab.h
SRCS= ${SHSRCS} ${GENSRCS} ${GENHDRS} y.tab.h
NOSHARED?= yes
# MLINKS for Shell built in commands for which there are no userland
# utilities of the same name are handled with the associated manpage,
-6
View File
@@ -1,6 +0,0 @@
# $FreeBSD$
PROG= uuidgen
WARNS?= 4
.include <bsd.prog.mk>
-79
View File
@@ -1,79 +0,0 @@
.\" Copyright (c) 2002 Marcel Moolenaar
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\"
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd May 23, 2002
.Dt UUIDGEN 1
.Os
.Sh NAME
.Nm uuidgen
.Nd generate universally unique identifiers
.Sh SYNOPSIS
.Nm
.Op Fl 1
.Op Fl n Ar count
.Op Fl o Ar filename
.Sh DESCRIPTION
The
.Nm
utility by default generates a single universally unique identifier (UUID),
also known as a globally unique identifier (GUID).
The UUID is written to stdout by default.
The following options can be used to change the behaviour of
.Nm :
.Bl -tag -width indent
.It Fl 1
This option only has effect if multiple identifiers are to be generated and
instructs
.Nm
to not generate them in batch, but one at a time.
.It Fl n
This option controls the number of identifiers generated.
By default, multiple
identifiers are generated in batch.
.It Fl o
Redirect output to
.Ar filename
instead of stdout.
.El
.Pp
Batched generation yields a dense set of identifiers in such a way that there
is no identifier that is larger than the smallest identifier in the set and
smaller than the largest identifier in the set and that is not already in the
set.
.Pp
When generating the identifiers one at a time, the identifiers will be close
to each other, but operating system latency and processing time will be
reflected in the distance between two successive identifiers.
.Sh DIAGNOSTICS
.Ex -std
.Sh SEE ALSO
.Xr uuidgen 2 ,
.Xr uuid 3
.Sh HISTORY
The
.Nm
command first appeared in
.Fx 5.0 .
-113
View File
@@ -1,113 +0,0 @@
/*
* Copyright (c) 2002 Marcel Moolenaar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <uuid.h>
static void
usage(void)
{
(void)fprintf(stderr, "usage: uuidgen [-1] [-n count] [-o filename]\n");
exit(1);
}
int
main(int argc, char *argv[])
{
FILE *fp;
uuid_t *store, *uuid;
char *p;
int ch, count, i, iterate;
count = -1; /* no count yet */
fp = stdout; /* default output file */
iterate = 0; /* not one at a time */
while ((ch = getopt(argc, argv, "1n:o:")) != -1)
switch (ch) {
case '1':
iterate = 1;
break;
case 'n':
if (count > 0)
usage();
count = strtol(optarg, &p, 10);
if (*p != 0 || count < 1)
usage();
break;
case 'o':
if (fp != stdout)
errx(1, "multiple output files not allowed");
fp = fopen(optarg, "w");
if (fp == NULL)
err(1, "fopen");
break;
default:
usage();
}
argv += optind;
argc -= optind;
if (argc)
usage();
if (count == -1)
count = 1;
store = (uuid_t*)malloc(sizeof(uuid_t) * count);
if (store == NULL)
err(1, "malloc()");
if (!iterate) {
/* Get them all in a single batch */
if (uuidgen(store, count) != 0)
err(1, "uuidgen()");
} else {
uuid = store;
for (i = 0; i < count; i++) {
if (uuidgen(uuid++, 1) != 0)
err(1, "uuidgen()");
}
}
uuid = store;
while (count--) {
uuid_to_string(uuid++, &p, NULL);
fprintf(fp, "%s\n", p);
free(p);
}
free(store);
if (fp != stdout)
fclose(fp);
return (0);
}
+110
View File
@@ -0,0 +1,110 @@
/* xsize.h -- Checked size_t computations.
Copyright (C) 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _XSIZE_H
#define _XSIZE_H
/* Get size_t. */
#include <stddef.h>
/* Get SIZE_MAX. */
#include <limits.h>
#if HAVE_STDINT_H
# include <stdint.h>
#else
#define SIZE_MAX UINT_MAX /* XXX */
#endif
/* The size of memory objects is often computed through expressions of
type size_t. Example:
void* p = malloc (header_size + n * element_size).
These computations can lead to overflow. When this happens, malloc()
returns a piece of memory that is way too small, and the program then
crashes while attempting to fill the memory.
To avoid this, the functions and macros in this file check for overflow.
The convention is that SIZE_MAX represents overflow.
malloc (SIZE_MAX) is not guaranteed to fail -- think of a malloc
implementation that uses mmap --, it's recommended to use size_overflow_p()
or size_in_bounds_p() before invoking malloc().
The example thus becomes:
size_t size = xsum (header_size, xtimes (n, element_size));
void *p = (size_in_bounds_p (size) ? malloc (size) : NULL);
*/
/* Convert an arbitrary value >= 0 to type size_t. */
#define xcast_size_t(N) \
((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
/* Sum of two sizes, with overflow check. */
static inline size_t
#if __GNUC__ >= 3
__attribute__ ((__pure__))
#endif
xsum (size_t size1, size_t size2)
{
size_t sum = size1 + size2;
return (sum >= size1 ? sum : SIZE_MAX);
}
/* Sum of three sizes, with overflow check. */
static inline size_t
#if __GNUC__ >= 3
__attribute__ ((__pure__))
#endif
xsum3 (size_t size1, size_t size2, size_t size3)
{
return xsum (xsum (size1, size2), size3);
}
/* Sum of four sizes, with overflow check. */
static inline size_t
#if __GNUC__ >= 3
__attribute__ ((__pure__))
#endif
xsum4 (size_t size1, size_t size2, size_t size3, size_t size4)
{
return xsum (xsum (xsum (size1, size2), size3), size4);
}
/* Maximum of two sizes, with overflow check. */
static inline size_t
#if __GNUC__ >= 3
__attribute__ ((__pure__))
#endif
xmax (size_t size1, size_t size2)
{
/* No explicit check is needed here, because for any n:
max (SIZE_MAX, n) == SIZE_MAX and max (n, SIZE_MAX) == SIZE_MAX. */
return (size1 >= size2 ? size1 : size2);
}
/* Multiplication of a count with an element size, with overflow check.
The count must be >= 0 and the element size must be > 0.
This is a macro, not an inline function, so that it works correctly even
when N is of a wider tupe and N > SIZE_MAX. */
#define xtimes(N, ELSIZE) \
((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX)
/* Check for overflow. */
#define size_overflow_p(SIZE) \
((SIZE) == SIZE_MAX)
/* Check against overflow. */
#define size_in_bounds_p(SIZE) \
((SIZE) != SIZE_MAX)
#endif /* _XSIZE_H */
+13
View File
@@ -1054,6 +1054,19 @@ call_in_directory (pathname, func, data)
char *rdirp;
int reposdirname_absolute;
/* For security reasons, if PATHNAME is absolute or attemps to ascend
* outside of the current sanbbox, we abort. The server should not send us
* anything but relative paths which remain inside the sandbox here.
* Anything less means a trojan CVS server could create and edit arbitrary
* files on the client.
*/
if (isabsolute (pathname) || pathname_levels (pathname) > 0)
{
error (0, 0,
"Server attempted to update a file via an invalid pathname:");
error (1, 0, "`%s'.", pathname);
}
reposname = NULL;
read_line (&reposname);
assert (reposname != NULL);
+6 -1
View File
@@ -481,7 +481,12 @@ commit (argc, argv)
operate on, and only work with those files in the future.
This saves time--we don't want to search the file system
of the working directory twice. */
find_args.argv = (char **) xmalloc (find_args.argc * sizeof (char **));
if (size_overflow_p (xtimes (find_args.argc, sizeof (char **))))
{
find_args.argc = 0;
return 0;
}
find_args.argv = xmalloc (xtimes (find_args.argc, sizeof (char **)));
find_args.argc = 0;
walklist (find_args.ulist, copy_ulist, &find_args);
+4
View File
@@ -41,6 +41,10 @@
#include "popen.h"
#endif
/* Begin GNULIB headers. */
#include "xsize.h"
/* End GNULIB headers. */
#ifdef STDC_HEADERS
#include <stdlib.h>
#else
+7 -1
View File
@@ -988,8 +988,14 @@ expand_wild (argc, argv, pargc, pargv)
char ***pargv;
{
int i;
if (size_overflow_p (xtimes (argc, sizeof (char *)))) {
*pargc = 0;
*pargv = NULL;
error (0, 0, "expand_wild: too many arguments");
return;
}
*pargc = argc;
*pargv = (char **) xmalloc (argc * sizeof (char *));
*pargv = xmalloc (xtimes (argc, sizeof (char *)));
for (i = 0; i < argc; ++i)
(*pargv)[i] = xstrdup (argv[i]);
}
+24 -9
View File
@@ -414,8 +414,11 @@ history (argc, argv)
working = 1;
break;
case 'X': /* Undocumented debugging flag */
#ifdef DEBUG
histfile = optarg;
#endif
break;
case 'D': /* Since specified date */
if (*since_rev || *since_tag || *backto)
{
@@ -890,9 +893,13 @@ save_user (name)
{
if (user_count == user_max)
{
user_max += USER_INCREMENT;
user_list = (char **) xrealloc ((char *) user_list,
(int) user_max * sizeof (char *));
user_max = xsum (user_max, USER_INCREMENT);
if (size_overflow_p (xtimes (user_max, sizeof (char *))))
{
error (0, 0, "save_user: too many users");
return;
}
user_list = xrealloc (user_list, xtimes (user_max, sizeof (char *)));
}
user_list[user_count++] = xstrdup (name);
}
@@ -920,9 +927,13 @@ save_file (dir, name, module)
if (file_count == file_max)
{
file_max += FILE_INCREMENT;
file_list = (struct file_list_str *) xrealloc ((char *) file_list,
file_max * sizeof (*fl));
file_max = xsum (file_max, FILE_INCREMENT);
if (size_overflow_p (xtimes (file_max, sizeof (*fl))))
{
error (0, 0, "save_file: too many files");
return;
}
file_list = xrealloc (file_list, xtimes (file_max, sizeof (*fl)));
}
fl = &file_list[file_count++];
fl->l_file = cp = xmalloc (strlen (dir) + strlen (name) + 2);
@@ -961,9 +972,13 @@ save_module (module)
{
if (mod_count == mod_max)
{
mod_max += MODULE_INCREMENT;
mod_list = (char **) xrealloc ((char *) mod_list,
mod_max * sizeof (char *));
mod_max = xsum (mod_max, MODULE_INCREMENT);
if (size_overflow_p (xtimes (mod_max, sizeof (char *))))
{
error (0, 0, "save_module: too many modules");
return;
}
mod_list = xrealloc (mod_list, xtimes (mod_max, sizeof (char *)));
}
mod_list[mod_count++] = xstrdup (module);
}
+37
View File
@@ -159,6 +159,43 @@ do_module (db, mname, m_type, msg, callback_proc, where, shorten,
}
#endif
/* Don't process absolute directories. Anything else could be a security
* problem. Before this check was put in place:
*
* $ cvs -d:fork:/cvsroot co /foo
* cvs server: warning: cannot make directory CVS in /: Permission denied
* cvs [server aborted]: cannot make directory /foo: Permission denied
* $
*/
if (isabsolute (mname))
error (1, 0, "Absolute module reference invalid: `%s'", mname);
/* Similarly for directories that attempt to step above the root of the
* repository.
*/
if (pathname_levels (mname) > 0)
error (1, 0, "up-level in module reference (`..') invalid: `%s'.",
mname);
/* Don't process absolute directories. Anything else could be a security
* problem. Before this check was put in place:
*
* $ cvs -d:fork:/cvsroot co /foo
* cvs server: warning: cannot make directory CVS in /: Permission denied
* cvs [server aborted]: cannot make directory /foo: Permission denied
* $
*/
if (isabsolute (mname))
error (1, 0, "Absolute module reference invalid: `%s'", mname);
/* Similarly for directories that attempt to step above the root of the
* repository.
*/
if (pathname_levels (mname) > 0)
error (1, 0, "up-level in module reference (`..') invalid: `%s'.",
mname);
/* if this is a directory to ignore, add it to that list */
if (mname[0] == '!' && mname[1] != '\0')
{
+125 -14
View File
@@ -927,7 +927,7 @@ serve_max_dotdot (arg)
int i;
char *p;
if (lim < 0)
if (lim < 0 || lim > 10000)
return;
p = xmalloc (strlen (server_temp_dir) + 2 * lim + 10);
if (p == NULL)
@@ -1647,9 +1647,28 @@ serve_unchanged (arg)
&& strlen (arg) == cp - name
&& strncmp (arg, name, cp - name) == 0)
{
timefield = strchr (cp + 1, '/') + 1;
if (*timefield != '=')
if (!(timefield = strchr (cp + 1, '/')) || *++timefield == '\0')
{
/* We didn't find the record separator or it is followed by
* the end of the string, so just exit.
*/
if (alloc_pending (80))
sprintf (pending_error_text,
"E Malformed Entry encountered.");
return;
}
/* If the time field is not currently empty, then one of
* serve_modified, serve_is_modified, & serve_unchanged were
* already called for this file. We would like to ignore the
* reinvocation silently or, better yet, exit with an error
* message, but we just avoid the copy-forward and overwrite the
* value from the last invocation instead. See the comment below
* for more.
*/
if (*timefield == '/')
{
/* Copy forward one character. Space was allocated for this
* already in serve_entry(). */
cp = timefield + strlen (timefield);
cp[1] = '\0';
while (cp > timefield)
@@ -1657,8 +1676,17 @@ serve_unchanged (arg)
*cp = cp[-1];
--cp;
}
*timefield = '=';
}
/* If *TIMEFIELD wasn't "/", we assume that it was because of
* multiple calls to Is-Modified & Unchanged by the client and
* just overwrite the value from the last call. Technically, we
* should probably either ignore calls after the first or send the
* client an error, since the client/server protocol specification
* specifies that only one call to either Is-Modified or Unchanged
* is allowed, but broken versions of WinCVS & TortoiseCVS rely on
* this behavior.
*/
*timefield = '=';
break;
}
}
@@ -1691,9 +1719,28 @@ serve_is_modified (arg)
&& strlen (arg) == cp - name
&& strncmp (arg, name, cp - name) == 0)
{
timefield = strchr (cp + 1, '/') + 1;
if (!(timefield[0] == 'M' && timefield[1] == '/'))
if (!(timefield = strchr (cp + 1, '/')) || *++timefield == '\0')
{
/* We didn't find the record separator or it is followed by
* the end of the string, so just exit.
*/
if (alloc_pending (80))
sprintf (pending_error_text,
"E Malformed Entry encountered.");
return;
}
/* If the time field is not currently empty, then one of
* serve_modified, serve_is_modified, & serve_unchanged were
* already called for this file. We would like to ignore the
* reinvocation silently or, better yet, exit with an error
* message, but we just avoid the copy-forward and overwrite the
* value from the last invocation instead. See the comment below
* for more.
*/
if (*timefield == '/')
{
/* Copy forward one character. Space was allocated for this
* already in serve_entry(). */
cp = timefield + strlen (timefield);
cp[1] = '\0';
while (cp > timefield)
@@ -1701,8 +1748,17 @@ serve_is_modified (arg)
*cp = cp[-1];
--cp;
}
*timefield = 'M';
}
/* If *TIMEFIELD wasn't "/", we assume that it was because of
* multiple calls to Is-Modified & Unchanged by the client and
* just overwrite the value from the last call. Technically, we
* should probably either ignore calls after the first or send the
* client an error, since the client/server protocol specification
* specifies that only one call to either Is-Modified or Unchanged
* is allowed, but broken versions of WinCVS & TortoiseCVS rely on
* this behavior.
*/
*timefield = 'M';
if (kopt != NULL)
{
if (alloc_pending (strlen (name) + 80))
@@ -1757,8 +1813,29 @@ serve_entry (arg)
{
struct an_entry *p;
char *cp;
int i = 0;
if (error_pending()) return;
p = (struct an_entry *) xmalloc (sizeof (struct an_entry));
/* Verify that the entry is well-formed. This can avoid problems later.
* At the moment we only check that the Entry contains five slashes in
* approximately the correct locations since some of the code makes
* assumptions about this.
*/
cp = arg;
if (*cp == 'D') cp++;
while (i++ < 5)
{
if (!cp || *cp != '/')
{
if (alloc_pending (80))
sprintf (pending_error_text,
"E protocol error: Malformed Entry");
return;
}
cp = strchr (cp + 1, '/');
}
p = xmalloc (sizeof (struct an_entry));
if (p == NULL)
{
pending_error = ENOMEM;
@@ -1990,6 +2067,9 @@ serve_notify (arg)
{
char *cp;
if (!data[0])
goto error;
if (strchr (data, '+'))
goto error;
@@ -2122,6 +2202,14 @@ serve_argument (arg)
if (error_pending()) return;
if (argument_count >= 10000)
{
if (alloc_pending (80))
sprintf (pending_error_text,
"E Protocol error: too many arguments");
return;
}
if (argument_vector_size <= argument_count)
{
argument_vector_size *= 2;
@@ -2152,6 +2240,14 @@ serve_argumentx (arg)
if (error_pending()) return;
if (argument_count <= 1)
{
if (alloc_pending (80))
sprintf (pending_error_text,
"E Protocol error: called argumentx without prior call to argument");
return;
}
p = argument_vector[argument_count - 1];
p = xrealloc (p, strlen (p) + 1 + strlen (arg) + 1);
if (p == NULL)
@@ -2508,7 +2604,7 @@ check_command_legal_p (cmd_name)
save some code here... -kff */
/* Chop newline by hand, for strcmp()'s sake. */
if (linebuf[num_red - 1] == '\n')
if (num_red > 0 && linebuf[num_red - 1] == '\n')
linebuf[num_red - 1] = '\0';
if (strcmp (linebuf, CVS_Username) == 0)
@@ -2563,7 +2659,7 @@ check_command_legal_p (cmd_name)
while ((num_red = getline (&linebuf, &linebuf_len, fp)) >= 0)
{
/* Chop newline by hand, for strcmp()'s sake. */
if (linebuf[num_red - 1] == '\n')
if (num_red > 0 && linebuf[num_red - 1] == '\n')
linebuf[num_red - 1] = '\0';
if (strcmp (linebuf, CVS_Username) == 0)
@@ -5237,10 +5333,11 @@ error ENOMEM Virtual memory exhausted.\n");
#if defined (HAVE_KERBEROS) || defined (AUTH_SERVER_SUPPORT) || defined (HAVE_GSSAPI)
static void switch_to_user PROTO((const char *));
static void switch_to_user PROTO((const char *, const char *));
static void
switch_to_user (username)
switch_to_user (cvs_username, username)
const char *cvs_username; /* Only used for error messages. */
const char *username;
{
struct passwd *pw;
@@ -5257,6 +5354,20 @@ error 0 %s: no such user\n", username);
error_exit ();
}
if (pw->pw_uid == 0)
{
#ifdef HAVE_SYSLOG_H
/* FIXME: Can the IP address of the connecting client be retrieved
* and printed here?
*/
syslog (LOG_DAEMON | LOG_ALERT,
"attempt to root from account: %s", cvs_username
);
#endif
printf("error 0: root not allowed\n");
error_exit ();
}
#if HAVE_INITGROUPS
if (initgroups (pw->pw_name, pw->pw_gid) < 0
# ifdef EPERM
@@ -5834,7 +5945,7 @@ pserver_authenticate_connection ()
strcpy (Pserver_Repos, repository);
/* Switch to run as this user. */
switch_to_user (host_user);
switch_to_user (username, host_user);
free (host_user);
free (tmp);
free (repository);
@@ -6027,7 +6138,7 @@ gserver_authenticate_connection ()
error (1, errno, "fwrite failed");
}
switch_to_user (buf);
switch_to_user ("GSSAPI", buf);
printf ("I LOVE YOU\n");
fflush (stdout);
+28 -6
View File
@@ -238,6 +238,30 @@ wrap_unparse_rcs_options (line, first_call_p)
}
#endif /* SERVER_SUPPORT || CLIENT_SUPPORT */
/*
* Remove fmt str specifier other than %% or %s. And allow
* only max_s %s specifiers
*/
wrap_clean_fmt_str(char *fmt, int max_s)
{
while (*fmt) {
if (fmt[0] == '%' && fmt[1])
{
if (fmt[1] == '%')
fmt++;
else
if (fmt[1] == 's' && max_s > 0)
{
max_s--;
fmt++;
} else
*fmt = ' ';
}
fmt++;
}
return;
}
/*
* Open a file and read lines, feeding each line to a line parser. Arrange
* for keeping a temporary list of wrappers at the end, if the "temp"
@@ -558,9 +582,8 @@ wrap_tocvs_process_file(fileName)
args = xmalloc (strlen (e->tocvsFilter)
+ strlen (fileName)
+ strlen (buf));
/* FIXME: sprintf will blow up if the format string contains items other
than %s, or contains too many %s's. We should instead be parsing
e->tocvsFilter ourselves and giving a real error. */
wrap_clean_fmt_str(e->tocvsFilter, 2);
sprintf (args, e->tocvsFilter, fileName, buf);
run_setup (args);
run_exec(RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL|RUN_REALLY );
@@ -592,9 +615,8 @@ wrap_fromcvs_process_file(fileName)
args = xmalloc (strlen (e->fromcvsFilter)
+ strlen (fileName));
/* FIXME: sprintf will blow up if the format string contains items other
than %s, or contains too many %s's. We should instead be parsing
e->fromcvsFilter ourselves and giving a real error. */
wrap_clean_fmt_str(e->fromcvsFilter, 1);
sprintf (args, e->fromcvsFilter, fileName);
run_setup (args);
run_exec(RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL );
+11
View File
@@ -25,6 +25,17 @@ Boston, MA 02111-1307, USA. */
#undef TARGET_VERSION
#define TARGET_VERSION fprintf (stderr, " (FreeBSD/x86-64 ELF)");
#undef FBSD_TARGET_CPU_CPP_BUILTINS
#define FBSD_TARGET_CPU_CPP_BUILTINS() \
do \
{ \
if (TARGET_64BIT) \
{ \
builtin_define ("__LP64__"); \
} \
} \
while (0)
/* Provide a LINK_SPEC appropriate for the FreeBSD/x86-64 ELF target.
This is a copy of LINK_SPEC from <i386/freebsd.h> tweaked for
the x86-64 target. */
+1
View File
@@ -922,6 +922,7 @@ int blen;
}
#if (SOLARIS || \
(defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) || \
(defined(__FreeBSD__) && (__FreeBSD_version >= 501113)) || \
(defined(OpenBSD) && (OpenBSD >= 199603))) || defined(linux)
{
char ifname[sizeof(ipf->fl_ifname) + 1];
+17 -14
View File
@@ -31,7 +31,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $P4: //depot/projects/openpam/lib/openpam_ttyconv.c#23 $
* $P4: //depot/projects/openpam/lib/openpam_ttyconv.c#24 $
*/
#include <sys/types.h>
@@ -119,7 +119,7 @@ prompt(const char *msg)
}
/* trim trailing whitespace */
for (len = strlen(buf); len > 0; --len)
if (!isspace(buf[len - 1]))
if (buf[len - 1] != '\r' && buf[len - 1] != '\n')
break;
buf[len] = '\0';
retval = strdup(buf);
@@ -166,26 +166,27 @@ openpam_ttyconv(int n,
struct pam_response **resp,
void *data)
{
struct pam_response *aresp;
int i;
ENTER();
(void)data;
if (n <= 0 || n > PAM_MAX_NUM_MSG)
RETURNC(PAM_CONV_ERR);
if ((*resp = calloc(n, sizeof **resp)) == NULL)
if ((aresp = calloc(n, sizeof *aresp)) == NULL)
RETURNC(PAM_BUF_ERR);
for (i = 0; i < n; ++i) {
resp[i]->resp_retcode = 0;
resp[i]->resp = NULL;
aresp[i].resp_retcode = 0;
aresp[i].resp = NULL;
switch (msg[i]->msg_style) {
case PAM_PROMPT_ECHO_OFF:
(*resp[i]).resp = prompt_echo_off(msg[i]->msg);
if ((*resp[i]).resp == NULL)
aresp[i].resp = prompt_echo_off(msg[i]->msg);
if (aresp[i].resp == NULL)
goto fail;
break;
case PAM_PROMPT_ECHO_ON:
(*resp[i]).resp = prompt(msg[i]->msg);
if ((*resp[i]).resp == NULL)
aresp[i].resp = prompt(msg[i]->msg);
if (aresp[i].resp == NULL)
goto fail;
break;
case PAM_ERROR_MSG:
@@ -204,16 +205,18 @@ openpam_ttyconv(int n,
goto fail;
}
}
*resp = aresp;
RETURNC(PAM_SUCCESS);
fail:
for (i = 0; i < n; ++i) {
if ((*resp[i]).resp != NULL) {
memset((*resp[i]).resp, 0, strlen((*resp[i]).resp));
FREE((*resp[i]).resp);
if (aresp[i].resp != NULL) {
memset(aresp[i].resp, 0, strlen(aresp[i].resp));
FREE(aresp[i].resp);
}
}
memset(*resp, 0, n * sizeof **resp);
FREE(*resp);
memset(aresp, 0, n * sizeof *aresp);
FREE(aresp);
*resp = NULL;
RETURNC(PAM_CONV_ERR);
}
+20 -2
View File
@@ -64,6 +64,8 @@ krb5_boolean encode_as_rep_as_tgs_rep; /* bug compatibility */
krb5_boolean check_ticket_addresses;
krb5_boolean allow_null_ticket_addresses;
krb5_boolean allow_anonymous;
int trpolicy;
static const char *trpolicy_str;
static struct getarg_strings addresses_str; /* addresses to listen on */
krb5_addresses explicit_addresses;
@@ -293,9 +295,8 @@ configure(int argc, char **argv)
get_dbinfo();
if(max_request_str){
if(max_request_str)
max_request = parse_bytes(max_request_str, NULL);
}
if(max_request == 0){
p = krb5_config_get_string (context,
@@ -366,6 +367,23 @@ configure(int argc, char **argv)
allow_anonymous =
krb5_config_get_bool(context, NULL, "kdc",
"allow-anonymous", NULL);
trpolicy_str =
krb5_config_get_string_default(context, NULL, "always-check", "kdc",
"transited-policy", NULL);
if(strcasecmp(trpolicy_str, "always-check") == 0)
trpolicy = TRPOLICY_ALWAYS_CHECK;
else if(strcasecmp(trpolicy_str, "allow-per-principal") == 0)
trpolicy = TRPOLICY_ALLOW_PER_PRINCIPAL;
else if(strcasecmp(trpolicy_str, "always-honour-request") == 0)
trpolicy = TRPOLICY_ALWAYS_HONOUR_REQUEST;
else {
kdc_log(0, "unknown transited-policy: %s, reverting to always-check",
trpolicy_str);
trpolicy = TRPOLICY_ALWAYS_CHECK;
}
krb5_config_get_bool_default(context, NULL, TRUE, "kdc",
"enforce-transited-policy", NULL);
#ifdef KRB4
if(v4_realm == NULL){
p = krb5_config_get_string (context, NULL,
+22 -1
View File
@@ -31,7 +31,7 @@
.\"
.\" $Id: kdc.8,v 1.23 2003/04/06 17:48:40 lha Exp $
.\"
.Dd August 22, 2002
.Dd October 22, 2003
.Dt KDC 8
.Os HEIMDAL
.Sh NAME
@@ -185,6 +185,27 @@ Permit tickets with no addresses.
This option is only relevant when check-ticket-addresses is TRUE.
.It Li allow-anonymous = Va boolean
Permit anonymous tickets with no addresses.
.It Li transited-policy = Xo
.Li always-check \*(Ba
.Li allow-per-principal |
.Li always-honour-request
.Xc
This controls how KDC requests with the
.Li disable-transited-check
flag are handled. It can be one of:
.Bl -tag -width "xxx" -offset indent
.It Li always-check
Always check transited encoding, this is the default.
.It Li allow-per-principal
Currently this is identical to
.Li always-check .
In a future release, it will be possible to mark a principal as able
to handle unchecked requests.
.It Li always-honour-request
Always do what the client asked.
In a future release, it will be possible to force a check per
principal.
.El
.It encode_as_rep_as_tgs_rep = Va boolean
Encode AS-Rep as TGS-Rep to be bug-compatible with old DCE code.
The Heimdal clients allow both.
+4
View File
@@ -62,6 +62,10 @@ extern krb5_boolean encode_as_rep_as_tgs_rep;
extern krb5_boolean check_ticket_addresses;
extern krb5_boolean allow_null_ticket_addresses;
extern krb5_boolean allow_anonymous;
enum { TRPOLICY_ALWAYS_CHECK,
TRPOLICY_ALLOW_PER_PRINCIPAL,
TRPOLICY_ALWAYS_HONOUR_REQUEST };
extern int trpolicy;
extern int enable_524;
extern int enable_v4_cross_realm;
+120 -56
View File
@@ -496,8 +496,8 @@ as_rep(KDC_REQ *req,
krb5_enctype cetype, setype;
EncTicketPart et;
EncKDCRepPart ek;
krb5_principal client_princ, server_princ;
char *client_name, *server_name;
krb5_principal client_princ = NULL, server_princ = NULL;
char *client_name = NULL, *server_name = NULL;
krb5_error_code ret = 0;
const char *e_text = NULL;
krb5_crypto crypto;
@@ -506,27 +506,30 @@ as_rep(KDC_REQ *req,
memset(&rep, 0, sizeof(rep));
if(b->sname == NULL){
server_name = "<unknown server>";
ret = KRB5KRB_ERR_GENERIC;
e_text = "No server in request";
} else{
principalname2krb5_principal (&server_princ, *(b->sname), b->realm);
krb5_unparse_name(context, server_princ, &server_name);
}
if (ret) {
kdc_log(0, "AS-REQ malformed server name from %s", from);
goto out;
}
if(b->cname == NULL){
client_name = "<unknown client>";
ret = KRB5KRB_ERR_GENERIC;
e_text = "No client in request";
} else {
principalname2krb5_principal (&client_princ, *(b->cname), b->realm);
krb5_unparse_name(context, client_princ, &client_name);
}
kdc_log(0, "AS-REQ %s from %s for %s",
client_name, from, server_name);
if(ret)
if (ret) {
kdc_log(0, "AS-REQ malformed client name from %s", from);
goto out;
}
kdc_log(0, "AS-REQ %s from %s for %s", client_name, from, server_name);
ret = db_fetch(client_princ, &client);
if(ret){
@@ -842,13 +845,8 @@ as_rep(KDC_REQ *req,
copy_HostAddresses(b->addresses, et.caddr);
}
{
krb5_data empty_string;
krb5_data_zero(&empty_string);
et.transited.tr_type = DOMAIN_X500_COMPRESS;
et.transited.contents = empty_string;
}
et.transited.tr_type = DOMAIN_X500_COMPRESS;
krb5_data_zero(&et.transited.contents);
copy_EncryptionKey(&et.key, &ek.key);
@@ -930,9 +928,11 @@ as_rep(KDC_REQ *req,
ret = 0;
}
out2:
krb5_free_principal(context, client_princ);
if (client_princ)
krb5_free_principal(context, client_princ);
free(client_name);
krb5_free_principal(context, server_princ);
if (server_princ)
krb5_free_principal(context, server_princ);
free(server_name);
if(client)
free_ent(client);
@@ -1055,33 +1055,35 @@ check_tgs_flags(KDC_REQ_BODY *b, EncTicketPart *tgt, EncTicketPart *et)
}
static krb5_error_code
fix_transited_encoding(TransitedEncoding *tr,
fix_transited_encoding(krb5_boolean check_policy,
TransitedEncoding *tr,
EncTicketPart *et,
const char *client_realm,
const char *server_realm,
const char *tgt_realm)
{
krb5_error_code ret = 0;
if(strcmp(client_realm, tgt_realm) && strcmp(server_realm, tgt_realm)){
char **realms = NULL, **tmp;
int num_realms = 0;
int i;
if(tr->tr_type && tr->contents.length != 0) {
if(tr->tr_type != DOMAIN_X500_COMPRESS){
kdc_log(0, "Unknown transited type: %u",
tr->tr_type);
return KRB5KDC_ERR_TRTYPE_NOSUPP;
}
ret = krb5_domain_x500_decode(context,
tr->contents,
&realms,
&num_realms,
client_realm,
server_realm);
if(ret){
krb5_warn(context, ret, "Decoding transited encoding");
return ret;
}
}
char **realms, **tmp;
int num_realms;
int i;
if(tr->tr_type != DOMAIN_X500_COMPRESS) {
kdc_log(0, "Unknown transited type: %u", tr->tr_type);
return KRB5KDC_ERR_TRTYPE_NOSUPP;
}
ret = krb5_domain_x500_decode(context,
tr->contents,
&realms,
&num_realms,
client_realm,
server_realm);
if(ret){
krb5_warn(context, ret, "Decoding transited encoding");
return ret;
}
if(strcmp(client_realm, tgt_realm) && strcmp(server_realm, tgt_realm)) {
/* not us, so add the previous realm to transited set */
if (num_realms < 0 || num_realms + 1 > UINT_MAX/sizeof(*realms)) {
ret = ERANGE;
goto free_realms;
@@ -1098,16 +1100,46 @@ fix_transited_encoding(TransitedEncoding *tr,
goto free_realms;
}
num_realms++;
free_TransitedEncoding(tr);
tr->tr_type = DOMAIN_X500_COMPRESS;
ret = krb5_domain_x500_encode(realms, num_realms, &tr->contents);
if(ret)
krb5_warn(context, ret, "Encoding transited encoding");
free_realms:
for(i = 0; i < num_realms; i++)
free(realms[i]);
free(realms);
}
if(num_realms == 0) {
if(strcmp(client_realm, server_realm))
kdc_log(0, "cross-realm %s -> %s", client_realm, server_realm);
} else {
size_t l = 0;
char *rs;
for(i = 0; i < num_realms; i++)
l += strlen(realms[i]) + 2;
rs = malloc(l);
if(rs != NULL) {
*rs = '\0';
for(i = 0; i < num_realms; i++) {
if(i > 0)
strlcat(rs, ", ", l);
strlcat(rs, realms[i], l);
}
kdc_log(0, "cross-realm %s -> %s via [%s]", client_realm, server_realm, rs);
free(rs);
}
}
if(check_policy) {
ret = krb5_check_transited(context, client_realm,
server_realm,
realms, num_realms, NULL);
if(ret) {
krb5_warn(context, ret, "cross-realm %s -> %s",
client_realm, server_realm);
goto free_realms;
}
et->flags.transited_policy_checked = 1;
}
et->transited.tr_type = DOMAIN_X500_COMPRESS;
ret = krb5_domain_x500_encode(realms, num_realms, &et->transited.contents);
if(ret)
krb5_warn(context, ret, "Encoding transited encoding");
free_realms:
for(i = 0; i < num_realms; i++)
free(realms[i]);
free(realms);
return ret;
}
@@ -1175,8 +1207,28 @@ tgs_make_reply(KDC_REQ_BODY *b,
if(ret)
goto out;
copy_TransitedEncoding(&tgt->transited, &et.transited);
ret = fix_transited_encoding(&et.transited,
/* We should check the transited encoding if:
1) the request doesn't ask not to be checked
2) globally enforcing a check
3) principal requires checking
4) we allow non-check per-principal, but principal isn't marked as allowing this
5) we don't globally allow this
*/
#define GLOBAL_FORCE_TRANSITED_CHECK (trpolicy == TRPOLICY_ALWAYS_CHECK)
#define GLOBAL_ALLOW_PER_PRINCIPAL (trpolicy == TRPOLICY_ALLOW_PER_PRINCIPAL)
#define GLOBAL_ALLOW_DISABLE_TRANSITED_CHECK (trpolicy == TRPOLICY_ALWAYS_HONOUR_REQUEST)
/* these will consult the database in future release */
#define PRINCIPAL_FORCE_TRANSITED_CHECK(P) 0
#define PRINCIPAL_ALLOW_DISABLE_TRANSITED_CHECK(P) 0
ret = fix_transited_encoding(!f.disable_transited_check ||
GLOBAL_FORCE_TRANSITED_CHECK ||
PRINCIPAL_FORCE_TRANSITED_CHECK(server) ||
!((GLOBAL_ALLOW_PER_PRINCIPAL &&
PRINCIPAL_ALLOW_DISABLE_TRANSITED_CHECK(server)) ||
GLOBAL_ALLOW_DISABLE_TRANSITED_CHECK),
&tgt->transited, &et,
*krb5_princ_realm(context, client_principal),
*krb5_princ_realm(context, server->principal),
*krb5_princ_realm(context, krbtgt->principal));
@@ -1276,7 +1328,7 @@ tgs_make_reply(KDC_REQ_BODY *b,
DES3? */
ret = encode_reply(&rep, &et, &ek, etype, adtkt ? 0 : server->kvno, ekey,
0, &tgt->key, e_text, reply);
out:
out:
free_TGS_REP(&rep);
free_TransitedEncoding(&et.transited);
if(et.starttime)
@@ -1378,13 +1430,13 @@ get_krbtgt_realm(const PrincipalName *p)
}
static Realm
find_rpath(Realm r)
find_rpath(Realm crealm, Realm srealm)
{
const char *new_realm = krb5_config_get_string(context,
NULL,
"libdefaults",
"capath",
r,
"capaths",
crealm,
srealm,
NULL);
return (Realm)new_realm;
}
@@ -1676,7 +1728,7 @@ tgs_rep2(KDC_REQ_BODY *b,
if ((req_rlm = get_krbtgt_realm(&sp->name)) != NULL) {
if(loop++ < 2) {
new_rlm = find_rpath(req_rlm);
new_rlm = find_rpath(tgt->crealm, req_rlm);
if(new_rlm) {
kdc_log(5, "krbtgt for realm %s not found, trying %s",
req_rlm, new_rlm);
@@ -1725,6 +1777,18 @@ tgs_rep2(KDC_REQ_BODY *b,
}
#endif
if(strcmp(krb5_principal_get_realm(context, sp),
krb5_principal_get_comp_string(context, krbtgt->principal, 1)) != 0) {
char *tpn;
ret = krb5_unparse_name(context, krbtgt->principal, &tpn);
kdc_log(0, "Request with wrong krbtgt: %s", (ret == 0) ? tpn : "<unknown>");
if(ret == 0)
free(tpn);
ret = KRB5KRB_AP_ERR_NOT_US;
goto out;
}
ret = check_flags(client, cpn, server, spn, FALSE);
if(ret)
goto out;
+9
View File
@@ -540,6 +540,15 @@ krb5_change_password (
krb5_data */*result_code_string*/,
krb5_data */*result_string*/);
krb5_error_code
krb5_check_transited (
krb5_context /*context*/,
krb5_const_realm /*client_realm*/,
krb5_const_realm /*server_realm*/,
krb5_realm */*realms*/,
int /*num_realms*/,
int */*bad_realm*/);
krb5_error_code
krb5_check_transited_realms (
krb5_context /*context*/,
+34 -23
View File
@@ -129,6 +129,32 @@ krb5_decode_ap_req(krb5_context context,
return 0;
}
static krb5_error_code
check_transited(krb5_context context, Ticket *ticket, EncTicketPart *enc)
{
char **realms;
int num_realms;
krb5_error_code ret;
if(enc->transited.tr_type != DOMAIN_X500_COMPRESS)
return KRB5KDC_ERR_TRTYPE_NOSUPP;
if(enc->transited.contents.length == 0)
return 0;
ret = krb5_domain_x500_decode(context, enc->transited.contents,
&realms, &num_realms,
enc->crealm,
ticket->realm);
if(ret)
return ret;
ret = krb5_check_transited(context, enc->crealm,
ticket->realm,
realms, num_realms, NULL);
free(realms);
return ret;
}
krb5_error_code
krb5_decrypt_ticket(krb5_context context,
Ticket *ticket,
@@ -161,6 +187,14 @@ krb5_decrypt_ticket(krb5_context context,
krb5_clear_error_string (context);
return KRB5KRB_AP_ERR_TKT_EXPIRED;
}
if(!t.flags.transited_policy_checked) {
ret = check_transited(context, ticket, &t);
if(ret) {
free_EncTicketPart(&t);
return ret;
}
}
}
if(out)
@@ -209,29 +243,6 @@ out:
return ret;
}
#if 0
static krb5_error_code
check_transited(krb5_context context,
krb5_ticket *ticket)
{
char **realms;
int num_realms;
krb5_error_code ret;
if(ticket->ticket.transited.tr_type != DOMAIN_X500_COMPRESS)
return KRB5KDC_ERR_TRTYPE_NOSUPP;
ret = krb5_domain_x500_decode(ticket->ticket.transited.contents,
&realms, &num_realms,
ticket->client->realm,
ticket->server->realm);
if(ret)
return ret;
ret = krb5_check_transited_realms(context, realms, num_realms, NULL);
free(realms);
return ret;
}
#endif
krb5_error_code
krb5_verify_ap_req(krb5_context context,
+49
View File
@@ -308,6 +308,12 @@ krb5_domain_x500_decode(krb5_context context,
struct tr_realm *p, **q;
int ret;
if(tr.length == 0) {
*realms = NULL;
*num_realms = 0;
return 0;
}
/* split string in components */
ret = decode_realms(context, tr.data, tr.length, &r);
if(ret)
@@ -362,6 +368,9 @@ krb5_domain_x500_encode(char **realms, int num_realms, krb5_data *encoding)
char *s = NULL;
int len = 0;
int i;
krb5_data_zero(encoding);
if (num_realms == 0)
return 0;
for(i = 0; i < num_realms; i++){
len += strlen(realms[i]);
if(realms[i][0] == '/')
@@ -369,6 +378,8 @@ krb5_domain_x500_encode(char **realms, int num_realms, krb5_data *encoding)
}
len += num_realms - 1;
s = malloc(len + 1);
if (s == NULL)
return ENOMEM;
*s = '\0';
for(i = 0; i < num_realms; i++){
if(i && i < num_realms - 1)
@@ -382,6 +393,44 @@ krb5_domain_x500_encode(char **realms, int num_realms, krb5_data *encoding)
return 0;
}
krb5_error_code
krb5_check_transited(krb5_context context,
krb5_const_realm client_realm,
krb5_const_realm server_realm,
krb5_realm *realms,
int num_realms,
int *bad_realm)
{
char **tr_realms;
char **p;
int i;
if(num_realms == 0)
return 0;
tr_realms = krb5_config_get_strings(context, NULL,
"capaths",
client_realm,
server_realm,
NULL);
for(i = 0; i < num_realms; i++) {
for(p = tr_realms; p && *p; p++) {
if(strcmp(*p, realms[i]) == 0)
break;
}
if(p == NULL || *p == NULL) {
krb5_config_free_strings(tr_realms);
krb5_set_error_string (context, "no transit through realm %s",
realms[i]);
if(bad_realm)
*bad_realm = i;
return KRB5KRB_AP_ERR_ILL_CR_TKT;
}
}
krb5_config_free_strings(tr_realms);
return 0;
}
krb5_error_code
krb5_check_transited_realms(krb5_context context,
const char *const *realms,
+1 -1
View File
@@ -26,7 +26,7 @@
* major minor fix final patch/beta)
*/
#define OPENSSL_VERSION_NUMBER 0x0090703fL
#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.7c 30 Sep 2003"
#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.7c-p1 30 Sep 2003"
#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
+8
View File
@@ -1085,6 +1085,14 @@ start:
goto err;
}
/* Check we have a cipher to change to */
if (s->s3->tmp.new_cipher == NULL)
{
i=SSL_AD_UNEXPECTED_MESSAGE;
SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_CCS_RECEIVED_EARLY);
goto err;
}
rr->length=0;
if (s->msg_callback)
+1
View File
@@ -52,6 +52,7 @@ add path 'ttyP*' unhide
add path 'ttyQ*' unhide
add path 'ttyR*' unhide
add path 'ttyS*' unhide
add path fd unhide
add path 'fd/*' unhide
add path stdin unhide
add path stdout unhide
+8 -7
View File
@@ -11,9 +11,10 @@
; under anonymous FTP as
; file /domain/named.root
; on server FTP.INTERNIC.NET
; -OR- RS.INTERNIC.NET
;
; last update: Nov 5, 2002
; related version of root zone: 2002110501
; last update: Jan 29, 2004
; related version of root zone: 2004012900
;
;
; formerly NS.INTERNIC.NET
@@ -24,7 +25,7 @@ A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4
; formerly NS1.ISI.EDU
;
. 3600000 NS B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET. 3600000 A 128.9.0.107
B.ROOT-SERVERS.NET. 3600000 A 192.228.79.201
;
; formerly C.PSI.NET
;
@@ -61,22 +62,22 @@ H.ROOT-SERVERS.NET. 3600000 A 128.63.2.53
. 3600000 NS I.ROOT-SERVERS.NET.
I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17
;
; operated by VeriSign, Inc.
; operated by VeriSign, Inc.
;
. 3600000 NS J.ROOT-SERVERS.NET.
J.ROOT-SERVERS.NET. 3600000 A 192.58.128.30
;
; housed in LINX, operated by RIPE NCC
; operated by RIPE NCC
;
. 3600000 NS K.ROOT-SERVERS.NET.
K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129
;
; operated by IANA
; operated by ICANN
;
. 3600000 NS L.ROOT-SERVERS.NET.
L.ROOT-SERVERS.NET. 3600000 A 198.32.64.12
;
; housed in Japan, operated by WIDE
; operated by WIDE
;
. 3600000 NS M.ROOT-SERVERS.NET.
M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33
-46
View File
@@ -1,46 +0,0 @@
#!/bin/sh
#
# $NetBSD: nfslocking,v 1.6 2002/03/24 15:52:41 lukem Exp $
# $FreeBSD$
#
# PROVIDE: nfslocking
# REQUIRE: nfsserver nfsclient nfsd
# BEFORE: DAEMON
# KEYWORD: FreeBSD NetBSD
. /etc/rc.subr
arg=$1
case ${OSTYPE} in
FreeBSD)
RCVAR_SERVER="nfs_server_enable"
RCVAR_CLIENT="nfs_client_enable"
RCVAR_STATD="rpc_statd_enable"
RCVAR_LOCKD="rpc_lockd_enable"
;;
NetBSD)
RCVAR_SERVER="nfs_server"
RCVAR_CLIENT="nfs_client"
RCVAR_STATD="statd"
RCVAR_LOCKD="lockd"
;;
esac
start_precmd='checkyesno ${RCVAR_SERVER} || checkyesno ${RCVAR_CLIENT} ||
[ -n "$rc_force" ]'
stop_precmd=$start_precmd
status_precmd=$start_precmd
name="statd"
rcvar=${RCVAR_STATD}
command="/usr/sbin/rpc.${name}"
load_rc_config $name
run_rc_command "$arg"
name="lockd"
rcvar=${RCVAR_LOCKD}
command="/usr/sbin/rpc.${name}"
load_rc_config $name
run_rc_command "$arg"
-48
View File
@@ -1,48 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: ppp-user
# REQUIRE: netif isdnd
# KEYWORD: FreeBSD
. /etc/rc.subr
name="ppp"
rcvar="ppp_enable"
start_cmd="ppp_start"
stop_cmd=":"
ppp_start()
{
# Establish ppp mode.
#
if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \
-a "${ppp_mode}" != "dedicated" \
-a "${ppp_mode}" != "background" ]; then
ppp_mode="auto"
fi
ppp_command="/usr/sbin/ppp -quiet -${ppp_mode}"
# Switch on NAT mode?
#
case ${ppp_nat} in
[Yy][Ee][Ss])
ppp_command="${ppp_command} -nat"
;;
esac
ppp_command="${ppp_command} ${ppp_profile}"
echo "Starting ppp as \"${ppp_user}\""
su -m ${ppp_user} -c "exec ${ppp_command}"
# Re-Sync ipfilter so it picks up any new network interfaces
#
/etc/rc.d/ipfilter resync
}
load_rc_config $name
run_rc_command "$1"
-167
View File
@@ -1,167 +0,0 @@
#!/bin/sh
#
# Copyright (c) 1999 Matt Dillon
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#
# PROVIDE: diskless
# REQUIRE: initdiskless rcconf mountcritlocal
# BEFORE: addswap random
# KEYWORD: FreeBSD
dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
[ ${dlv:=0} -eq 0 ] && exit 0
name="diskless2"
# Provide a function for normalizing the mounting of memory
# filesystems. This should allow the rest of the code here to remain
# as close as possible between 5-current and 4-stable.
# $1 = size
# $2 = mount point
# $3 = (optional) bytes-per-inode
mount_md() {
if [ -n "$3" ]; then
bpi="-i $3"
fi
/sbin/mdmfs $bpi -s $1 -M md $2
}
# If there is a global system configuration file, suck it in.
#
if [ -r /etc/rc.subr ]; then
. /etc/rc.subr
load_rc_config $name
elif [ -r /etc/defaults/rc.conf ]; then
. /etc/defaults/rc.conf
source_rc_confs
elif [ -r /etc/rc.conf ]; then
. /etc/rc.conf
fi
# If we do not have a writable /var, create a memory
# filesystem for /var. We don't have /usr yet so
# use mkdir instead of touch to test. We want mount
# to record its mounts so we have to make sure /var/db
# exists before doing the mount -a.
#
if (/bin/mkdir /var/.diskless 2> /dev/null); then
rmdir /var/.diskless
else
echo "+++ mount_md of /var"
mount_md ${varsize:=32m} /var
fi
if [ ! -d /var/db ]; then
mkdir /var/db
fi
# Now we need the rest of our mounts, particularly /usr
#
mount -a # chown and chgrp are in /usr
# Populate /var
#
echo "+++ populate /var using /etc/mtree/BSD.var.dist"
/usr/sbin/mtree -deU -f /etc/mtree/BSD.var.dist -p /var > /dev/null
case ${sendmail_enable} in
[Nn][Oo][Nn][Ee])
;;
*)
/usr/sbin/mtree -deU -f /etc/mtree/BSD.sendmail.dist -p / > /dev/null
;;
esac
echo "+++ create log files based on the contents of /etc/newsyslog.conf"
LOGFILES=`/usr/bin/awk '$1 != "#" { printf "%s ", $1 } ' /etc/newsyslog.conf`
if [ -n "$LOGFILES" ]; then
/usr/bin/touch $LOGFILES
fi
echo "+++ create lastlog"
/usr/bin/touch /var/log/lastlog
# Make sure our aliases database is uptodate, the aliases may have
# been overriden in /conf.
#
/usr/bin/newaliases
# XXX make sure to create one dir for each printer as requested by lpd
#
# If we do not have a writable /tmp, create a memory
# filesystem for /tmp. If /tmp is a symlink (e.g. to /var/tmp,
# then it should already be writable).
#
if (/bin/mkdir /tmp/.diskless 2> /dev/null); then
rmdir /tmp/.diskless
else
if [ -h /tmp ]; then
echo "*** /tmp is a symlink to a non-writable area!"
echo "dropping into shell, ^D to continue anyway."
/bin/sh
else
mount_md ${tmpsize:=20480} /tmp
chmod 01777 /tmp
fi
fi
if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
# we have DEVFS, no worries...
true
elif (/bin/mkdir /dev/.diskless 2> /dev/null); then
# if /dev is writable assume it has already been populated
# via /etc/rc.d/initdiskless
#
rmdir /dev/.diskless
else
(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
mount_md 4096 /dev 512
(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
rm -f /tmp/dev.tmp
fi
# generate our hostname
#
if [ -z "`hostname -s`" -a \
"x`/bin/kenv dhcp.host-name`" != "x" ]; then
hostname=`/bin/kenv dhcp.host-name`
hostname $hostname
echo "Hostname is $hostname"
fi
# if the info is available via dhcp/kenv
# build the resolv.conf
#
if [ ! -e /etc/resolv.conf -a \
"x`/bin/kenv dhcp.domain-name-servers`" != "x" ]; then
echo domain `/bin/kenv dhcp.domain-name` > /etc/resolv.conf
set `/bin/kenv dhcp.domain-name-servers`
for ns in `IFS=','; echo $*`; do
echo nameserver $ns >> /etc/resolv.conf;
done
fi
-46
View File
@@ -1,46 +0,0 @@
#!/bin/sh
#
# $NetBSD: nfslocking,v 1.6 2002/03/24 15:52:41 lukem Exp $
# $FreeBSD$
#
# PROVIDE: nfslocking
# REQUIRE: nfsserver nfsclient nfsd
# BEFORE: DAEMON
# KEYWORD: FreeBSD NetBSD
. /etc/rc.subr
arg=$1
case ${OSTYPE} in
FreeBSD)
RCVAR_SERVER="nfs_server_enable"
RCVAR_CLIENT="nfs_client_enable"
RCVAR_STATD="rpc_statd_enable"
RCVAR_LOCKD="rpc_lockd_enable"
;;
NetBSD)
RCVAR_SERVER="nfs_server"
RCVAR_CLIENT="nfs_client"
RCVAR_STATD="statd"
RCVAR_LOCKD="lockd"
;;
esac
start_precmd='checkyesno ${RCVAR_SERVER} || checkyesno ${RCVAR_CLIENT} ||
[ -n "$rc_force" ]'
stop_precmd=$start_precmd
status_precmd=$start_precmd
name="statd"
rcvar=${RCVAR_STATD}
command="/usr/sbin/rpc.${name}"
load_rc_config $name
run_rc_command "$arg"
name="lockd"
rcvar=${RCVAR_LOCKD}
command="/usr/sbin/rpc.${name}"
load_rc_config $name
run_rc_command "$arg"
-167
View File
@@ -1,167 +0,0 @@
#!/bin/sh
#
# Copyright (c) 1999 Matt Dillon
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#
# PROVIDE: diskless
# REQUIRE: initdiskless rcconf mountcritlocal
# BEFORE: addswap random
# KEYWORD: FreeBSD
dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
[ ${dlv:=0} -eq 0 ] && exit 0
name="diskless2"
# Provide a function for normalizing the mounting of memory
# filesystems. This should allow the rest of the code here to remain
# as close as possible between 5-current and 4-stable.
# $1 = size
# $2 = mount point
# $3 = (optional) bytes-per-inode
mount_md() {
if [ -n "$3" ]; then
bpi="-i $3"
fi
/sbin/mdmfs $bpi -s $1 -M md $2
}
# If there is a global system configuration file, suck it in.
#
if [ -r /etc/rc.subr ]; then
. /etc/rc.subr
load_rc_config $name
elif [ -r /etc/defaults/rc.conf ]; then
. /etc/defaults/rc.conf
source_rc_confs
elif [ -r /etc/rc.conf ]; then
. /etc/rc.conf
fi
# If we do not have a writable /var, create a memory
# filesystem for /var. We don't have /usr yet so
# use mkdir instead of touch to test. We want mount
# to record its mounts so we have to make sure /var/db
# exists before doing the mount -a.
#
if (/bin/mkdir /var/.diskless 2> /dev/null); then
rmdir /var/.diskless
else
echo "+++ mount_md of /var"
mount_md ${varsize:=32m} /var
fi
if [ ! -d /var/db ]; then
mkdir /var/db
fi
# Now we need the rest of our mounts, particularly /usr
#
mount -a # chown and chgrp are in /usr
# Populate /var
#
echo "+++ populate /var using /etc/mtree/BSD.var.dist"
/usr/sbin/mtree -deU -f /etc/mtree/BSD.var.dist -p /var > /dev/null
case ${sendmail_enable} in
[Nn][Oo][Nn][Ee])
;;
*)
/usr/sbin/mtree -deU -f /etc/mtree/BSD.sendmail.dist -p / > /dev/null
;;
esac
echo "+++ create log files based on the contents of /etc/newsyslog.conf"
LOGFILES=`/usr/bin/awk '$1 != "#" { printf "%s ", $1 } ' /etc/newsyslog.conf`
if [ -n "$LOGFILES" ]; then
/usr/bin/touch $LOGFILES
fi
echo "+++ create lastlog"
/usr/bin/touch /var/log/lastlog
# Make sure our aliases database is uptodate, the aliases may have
# been overriden in /conf.
#
/usr/bin/newaliases
# XXX make sure to create one dir for each printer as requested by lpd
#
# If we do not have a writable /tmp, create a memory
# filesystem for /tmp. If /tmp is a symlink (e.g. to /var/tmp,
# then it should already be writable).
#
if (/bin/mkdir /tmp/.diskless 2> /dev/null); then
rmdir /tmp/.diskless
else
if [ -h /tmp ]; then
echo "*** /tmp is a symlink to a non-writable area!"
echo "dropping into shell, ^D to continue anyway."
/bin/sh
else
mount_md ${tmpsize:=20480} /tmp
chmod 01777 /tmp
fi
fi
if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
# we have DEVFS, no worries...
true
elif (/bin/mkdir /dev/.diskless 2> /dev/null); then
# if /dev is writable assume it has already been populated
# via /etc/rc.d/initdiskless
#
rmdir /dev/.diskless
else
(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
mount_md 4096 /dev 512
(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
rm -f /tmp/dev.tmp
fi
# generate our hostname
#
if [ -z "`hostname -s`" -a \
"x`/bin/kenv dhcp.host-name`" != "x" ]; then
hostname=`/bin/kenv dhcp.host-name`
hostname $hostname
echo "Hostname is $hostname"
fi
# if the info is available via dhcp/kenv
# build the resolv.conf
#
if [ ! -e /etc/resolv.conf -a \
"x`/bin/kenv dhcp.domain-name-servers`" != "x" ]; then
echo domain `/bin/kenv dhcp.domain-name` > /etc/resolv.conf
set `/bin/kenv dhcp.domain-name-servers`
for ns in `IFS=','; echo $*`; do
echo nameserver $ns >> /etc/resolv.conf;
done
fi
-167
View File
@@ -1,167 +0,0 @@
#!/bin/sh
#
# Copyright (c) 1999 Matt Dillon
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#
# PROVIDE: diskless
# REQUIRE: initdiskless rcconf mountcritlocal
# BEFORE: addswap random
# KEYWORD: FreeBSD
dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
[ ${dlv:=0} -eq 0 ] && exit 0
name="diskless2"
# Provide a function for normalizing the mounting of memory
# filesystems. This should allow the rest of the code here to remain
# as close as possible between 5-current and 4-stable.
# $1 = size
# $2 = mount point
# $3 = (optional) bytes-per-inode
mount_md() {
if [ -n "$3" ]; then
bpi="-i $3"
fi
/sbin/mdmfs $bpi -s $1 -M md $2
}
# If there is a global system configuration file, suck it in.
#
if [ -r /etc/rc.subr ]; then
. /etc/rc.subr
load_rc_config $name
elif [ -r /etc/defaults/rc.conf ]; then
. /etc/defaults/rc.conf
source_rc_confs
elif [ -r /etc/rc.conf ]; then
. /etc/rc.conf
fi
# If we do not have a writable /var, create a memory
# filesystem for /var. We don't have /usr yet so
# use mkdir instead of touch to test. We want mount
# to record its mounts so we have to make sure /var/db
# exists before doing the mount -a.
#
if (/bin/mkdir /var/.diskless 2> /dev/null); then
rmdir /var/.diskless
else
echo "+++ mount_md of /var"
mount_md ${varsize:=32m} /var
fi
if [ ! -d /var/db ]; then
mkdir /var/db
fi
# Now we need the rest of our mounts, particularly /usr
#
mount -a # chown and chgrp are in /usr
# Populate /var
#
echo "+++ populate /var using /etc/mtree/BSD.var.dist"
/usr/sbin/mtree -deU -f /etc/mtree/BSD.var.dist -p /var > /dev/null
case ${sendmail_enable} in
[Nn][Oo][Nn][Ee])
;;
*)
/usr/sbin/mtree -deU -f /etc/mtree/BSD.sendmail.dist -p / > /dev/null
;;
esac
echo "+++ create log files based on the contents of /etc/newsyslog.conf"
LOGFILES=`/usr/bin/awk '$1 != "#" { printf "%s ", $1 } ' /etc/newsyslog.conf`
if [ -n "$LOGFILES" ]; then
/usr/bin/touch $LOGFILES
fi
echo "+++ create lastlog"
/usr/bin/touch /var/log/lastlog
# Make sure our aliases database is uptodate, the aliases may have
# been overriden in /conf.
#
/usr/bin/newaliases
# XXX make sure to create one dir for each printer as requested by lpd
#
# If we do not have a writable /tmp, create a memory
# filesystem for /tmp. If /tmp is a symlink (e.g. to /var/tmp,
# then it should already be writable).
#
if (/bin/mkdir /tmp/.diskless 2> /dev/null); then
rmdir /tmp/.diskless
else
if [ -h /tmp ]; then
echo "*** /tmp is a symlink to a non-writable area!"
echo "dropping into shell, ^D to continue anyway."
/bin/sh
else
mount_md ${tmpsize:=20480} /tmp
chmod 01777 /tmp
fi
fi
if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
# we have DEVFS, no worries...
true
elif (/bin/mkdir /dev/.diskless 2> /dev/null); then
# if /dev is writable assume it has already been populated
# via /etc/rc.d/initdiskless
#
rmdir /dev/.diskless
else
(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
mount_md 4096 /dev 512
(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
rm -f /tmp/dev.tmp
fi
# generate our hostname
#
if [ -z "`hostname -s`" -a \
"x`/bin/kenv dhcp.host-name`" != "x" ]; then
hostname=`/bin/kenv dhcp.host-name`
hostname $hostname
echo "Hostname is $hostname"
fi
# if the info is available via dhcp/kenv
# build the resolv.conf
#
if [ ! -e /etc/resolv.conf -a \
"x`/bin/kenv dhcp.domain-name-servers`" != "x" ]; then
echo domain `/bin/kenv dhcp.domain-name` > /etc/resolv.conf
set `/bin/kenv dhcp.domain-name-servers`
for ns in `IFS=','; echo $*`; do
echo nameserver $ns >> /etc/resolv.conf;
done
fi
-240
View File
@@ -1,240 +0,0 @@
#!/bin/sh
#
# Copyright (c) 1999 Matt Dillon
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#
# PROVIDE: initdiskless
# KEYWORD: FreeBSD
# On entry to this script the entire system consists of a read-only root
# mounted via NFS. We use the contents of /conf to create and populate
# memory filesystems. The kernel has run BOOTP and configured an interface
# (otherwise it would not have been able to mount the NFS root!)
#
# The following directories are scanned. Each sucessive directory overrides
# (is merged into) the previous one.
#
# /conf/base universal base
# /conf/default modified by a secondary universal base
# /conf/${ipba} modified based on the assigned broadcast IP
# /conf/${ip} modified based on the machine's assigned IP
#
# Each of these directories may contain any number of subdirectories which
# represent directories in / on the diskless machine. The existance of
# these subdirectories causes this script to create a MEMORY FILESYSTEM for
# /<sub_directory_name>. For example, if /conf/base/etc exists then a
# memory filesystem will be created for /etc.
#
# If a subdirectory contains the file 'diskless_remount' the contents of
# the file is used to remount the subdirectory prior to it being copied to
# the memory filesystem. For example, if /conf/base/etc/diskless_remount
# contains the string 'my.server.com:/etc' then my.server.com:/etc will be
# mounted in place of the subdirectory. This allows you to avoid making
# duplicates of system directories in /conf.
#
# If a subdirectory contains the file 'md_size', the contents of the
# file is used to determine the size of the memory filesystem, in 512
# byte sectors. The default is 10240 (5MB). You only have to specify an
# md_size if the default doesn't work for you (i.e. if it is too big or
# too small). For example, /conf/base/etc/md_size might contain '16384'.
#
# If /conf/<special_dir>/SUBDIR.cpio.gz exists, the file is cpio'd into
# the specified /SUBDIR (and a memory filesystem is created for /SUBDIR
# if necessary).
#
# If /conf/<special_dir>/SUBDIR.remove exists, the file contains a list
# of paths which are rm -rf'd relative to /SUBDIR.
#
# You will almost universally want to create a /conf/base/etc containing
# a diskless_remount and possibly an md_size file. You will then almost
# universally want to override rc.conf, rc.local, and fstab by creating
# /conf/default/etc/{rc.conf,rc.local,fstab}. Your fstab should be sure
# to mount a /usr... typically an NFS readonly /usr.
#
# NOTE! /etc/rc.d/diskless will create /var, /tmp, and /dev.
# Those filesystems should not be specified in /conf. At least not yet.
dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
[ ${dlv:=0} -eq 0 ] && exit 0
# chkerr:
#
# Routine to check for error
#
# checks error code and drops into shell on failure.
# if shell exits, terminates script as well as /etc/rc.
#
chkerr() {
case $1 in
0)
;;
*)
echo "$2 failed: dropping into /bin/sh"
/bin/sh
# RESUME
;;
esac
}
# Create a generic memory disk
#
mount_md() {
/sbin/mdmfs -i 4096 -s $1 -M md $2
}
# Create the memory filesystem if it has not already been created
#
create_md() {
if [ "x`eval echo \\$md_created_$1`" = "x" ]; then
if [ "x`eval echo \\$md_size_$1`" = "x" ]; then
md_size=10240
else
md_size=`eval echo \\$md_size_$1`
fi
mount_md $md_size /$1
/bin/chmod 755 /$1
eval md_created_$1=created
fi
}
# DEBUGGING
#
# set -v
# Figure out our interface and IP.
#
bootp_ifc=""
bootp_ipa=""
bootp_ipbca=""
iflist=`ifconfig -l`
for i in ${iflist} ; do
set `ifconfig ${i}`
while [ $# -ge 1 ] ; do
if [ "${bootp_ifc}" = "" -a "$1" = "inet" ] ; then
bootp_ifc=${i} ; bootp_ipa=${2} ; shift
fi
if [ "${bootp_ipbca}" = "" -a "$1" = "broadcast" ] ; then
bootp_ipbca=$2; shift
fi
shift
done
if [ "${bootp_ifc}" != "" ] ; then
break
fi
done
echo "Interface ${bootp_ifc} IP-Address ${bootp_ipa} Broadcast ${bootp_ipbca}"
# Figure out our NFS root path
#
set `mount -t nfs`
while [ $# -ge 1 ] ; do
if [ "$2" = "on" -a "$3" = "/" ]; then
nfsroot="$1"
break
fi
shift
done
# Resolve templates in /conf/base, /conf/default, /conf/${bootp_ipbca},
# and /conf/${bootp_ipa}. For each subdirectory found within these
# directories:
#
# - calculate memory filesystem sizes. If the subdirectory (prior to
# NFS remounting) contains the file 'md_size', the contents specified
# in 512 byte sectors will be used to size the memory filesystem. Otherwise
# 8192 sectors (4MB) is used.
#
# - handle NFS remounts. If the subdirectory contains the file
# diskless_remount, the contents of the file is NFS mounted over
# the directory. For example /conf/base/etc/diskless_remount
# might contain 'myserver:/etc'. NFS remounts allow you to avoid
# having to dup your system directories in /conf. Your server must
# be sure to export those filesystems -alldirs, however.
# If the diskless_remount file contains a string beginning with a
# '/' it is assumed that the local nfsroot should be prepended to
# it before attemping to the remount. This allows the root to be
# relocated without needing to change the remount files.
#
for i in base default ${bootp_ipbca} ${bootp_ipa} ; do
for j in /conf/$i/* ; do
# memory filesystem size specification
#
subdir=${j##*/}
if [ -d $j -a -f $j/md_size ]; then
eval md_size_$subdir=`cat $j/md_size`
fi
# NFS remount
#
if [ -d $j -a -f $j/diskless_remount ]; then
nfspt=`/bin/cat $j/diskless_remount`
if [ `expr "$nfspt" : '\(.\)'` = "/" ]; then
nfspt="${nfsroot}${nfspt}"
fi
mount_nfs $nfspt $j
chkerr $? "mount_nfs $nfspt $j"
fi
done
done
# - Create all required MFS filesystems and populate them from
# our templates. Support both a direct template and a dir.cpio.gz
# archive. Support dir.remove files containing a list of relative
# paths to remove.
#
# TODO:
# + find a way to assign a 'group' identifier to a machine
# so we can use group-specific configurations;
for i in base default ${bootp_ipbca} ${bootp_ipa} ; do
for j in /conf/$i/* ; do
subdir=${j##*/}
if [ -d $j ]; then
create_md $subdir
cp -Rp $j/* /$subdir
fi
done
for j in /conf/$i/*.cpio.gz ; do
subdir=${j%*.cpio.gz}
subdir=${subdir##*/}
if [ -f $j ]; then
create_md $subdir
echo "Loading /$subdir from cpio archive $j"
(cd / ; /stand/gzip -d < $j | /stand/cpio --extract -d )
fi
done
for j in /conf/$i/*.remove ; do
subdir=${j%*.remove}
subdir=${subdir##*/}
if [ -f $j ]; then
# doubly sure it is a memory disk before rm -rf'ing
create_md $subdir
(cd /$subdir; rm -rf `/bin/cat $j`)
fi
done
done
+2 -2
View File
@@ -132,8 +132,8 @@ GDB_VERSION= "5.2.1 (FreeBSD)"
gdbversion.c:
@echo '#include "version.h"' > ${.TARGET}
@echo 'const char version[] = ${GDB_VERSION};' >>${.TARGET}
@echo 'const char host_name[] = "${MACHINE_ARCH}-undermydesk-freebsd";' >>${.TARGET}
@echo 'const char target_name[] = "${TARGET_ARCH}-undermydesk-freebsd";' >>${.TARGET}
@echo 'const char host_name[] = "${MACHINE_ARCH}-unknown-freebsd";' >>${.TARGET}
@echo 'const char target_name[] = "${TARGET_ARCH}-unknown-freebsd";' >>${.TARGET}
xregex.h:
@echo '#include <gnuregex.h>' >${.TARGET}
+1 -1
View File
@@ -12,7 +12,7 @@ GCCDIR= ${.CURDIR}/../../../../contrib/gcc
# Machine description.
MD_FILE= ${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.md
target= ${TARGET_ARCH}-undermydesk-freebsd
target= ${TARGET_ARCH}-unknown-freebsd
CFLAGS+= -DIN_GCC -DHAVE_CONFIG_H
CFLAGS+= -DPREFIX=\"${TOOLS_PREFIX}/usr\"
+1 -1
View File
@@ -5,7 +5,7 @@
.PATH: ${GCCDIR}/config/${GCC_CPU}
.if ${TARGET_ARCH} == "i386" || ${TARGET_ARCH} == "amd64"
INCS= mmintrin.h xmmintrin.h
INCS= emmintrin.h mmintrin.h pmmintrin.h xmmintrin.h
.elif ${TARGET_ARCH} == "ia64"
INCS= ia64intrin.h
.endif
+1 -1
View File
@@ -250,7 +250,7 @@
#define HAVE_SIGVEC 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* #undef HAVE_STDINT_H */
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
-31
View File
@@ -1,31 +0,0 @@
$FreeBSD$
--- inc-hist.texinfo.orig Wed Apr 11 08:20:01 2001
+++ inc-hist.texinfo Wed Apr 11 08:21:57 2001
@@ -26,9 +26,9 @@
@node Using History Interactively
@chapter Using History Interactively
-@ifclear BashFeatures
-@defcodeindex bt
-@end ifclear
+@c @ifclear BashFeatures
+@c @defcodeindex bt
+@c @end ifclear
@ifset BashFeatures
This chapter describes how to use the @sc{gnu} History Library
@@ -39,9 +39,10 @@
@end ifset
@ifclear BashFeatures
This chapter describes how to use the @sc{gnu} History Library interactively,
-from a user's standpoint. It should be considered a user's guide. For
-information on using the @sc{gnu} History Library in your own programs,
-@pxref{Programming with GNU History}.
+from a user's standpoint.
+@c It should be considered a user's guide. For
+@c information on using the @sc{gnu} History Library in your own programs,
+@c @pxref{Programming with GNU History}.
@end ifclear
@ifset BashFeatures
+2 -1
View File
@@ -55,12 +55,13 @@
.ds doc-str-Lb-libvgl Video Graphics Library (libvgl, \-lvgl)
.
.\" Default .Os value
.ds doc-default-operating-system FreeBSD\~5.1
.ds doc-default-operating-system FreeBSD\~5.2.1
.
.\" FreeBSD releases not found in doc-common
.ds doc-operating-system-FreeBSD-4.9 4.9
.ds doc-operating-system-FreeBSD-5.1 5.1
.ds doc-operating-system-FreeBSD-5.2 5.2
.ds doc-operating-system-FreeBSD-5.2.1 5.2.1
.
.ec
.
-228
View File
@@ -1,228 +0,0 @@
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* This code is derived from software contributed to Berkeley by
* Paul Borman at Krystal Technologies.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)ctype.h 8.4 (Berkeley) 1/21/94
* $FreeBSD$
*/
#ifndef _CTYPE_H_
#define _CTYPE_H_
#include <sys/cdefs.h>
#include <sys/_types.h>
#define _CTYPE_A 0x00000100L /* Alpha */
#define _CTYPE_C 0x00000200L /* Control */
#define _CTYPE_D 0x00000400L /* Digit */
#define _CTYPE_G 0x00000800L /* Graph */
#define _CTYPE_L 0x00001000L /* Lower */
#define _CTYPE_P 0x00002000L /* Punct */
#define _CTYPE_S 0x00004000L /* Space */
#define _CTYPE_U 0x00008000L /* Upper */
#define _CTYPE_X 0x00010000L /* X digit */
#define _CTYPE_B 0x00020000L /* Blank */
#define _CTYPE_R 0x00040000L /* Print */
#define _CTYPE_I 0x00080000L /* Ideogram */
#define _CTYPE_T 0x00100000L /* Special */
#define _CTYPE_Q 0x00200000L /* Phonogram */
#define _CTYPE_SW0 0x20000000L /* 0 width character */
#define _CTYPE_SW1 0x40000000L /* 1 width character */
#define _CTYPE_SW2 0x80000000L /* 2 width character */
#define _CTYPE_SW3 0xc0000000L /* 3 width character */
__BEGIN_DECLS
int isalnum(int);
int isalpha(int);
int iscntrl(int);
int isdigit(int);
int isgraph(int);
int islower(int);
int isprint(int);
int ispunct(int);
int isspace(int);
int isupper(int);
int isxdigit(int);
int tolower(int);
int toupper(int);
#if __XSI_VISIBLE
int _tolower(int);
int _toupper(int);
int isascii(int);
int toascii(int);
#endif
#if __BSD_VISIBLE
int digittoint(int);
int isblank(int);
int ishexnumber(int);
int isideogram(int);
int isnumber(int);
int isphonogram(int);
int isrune(int);
int isspecial(int);
#endif
__END_DECLS
#define isalnum(c) __istype((c), _CTYPE_A|_CTYPE_D)
#define isalpha(c) __istype((c), _CTYPE_A)
#define iscntrl(c) __istype((c), _CTYPE_C)
#define isdigit(c) __isctype((c), _CTYPE_D) /* ANSI -- locale independent */
#define isgraph(c) __istype((c), _CTYPE_G)
#define islower(c) __istype((c), _CTYPE_L)
#define isprint(c) __istype((c), _CTYPE_R)
#define ispunct(c) __istype((c), _CTYPE_P)
#define isspace(c) __istype((c), _CTYPE_S)
#define isupper(c) __istype((c), _CTYPE_U)
#define isxdigit(c) __isctype((c), _CTYPE_X) /* ANSI -- locale independent */
#define tolower(c) __tolower(c)
#define toupper(c) __toupper(c)
#if __XSI_VISIBLE
/*
* POSIX.1-2001 specifies _tolower() and _toupper() to be macros equivalent to
* tolower() and toupper() respectively, minus extra checking to ensure that
* the argument is a lower or uppercase letter respectively. We've chosen to
* implement these macros with the same error checking as tolower() and
* toupper() since this doesn't violate the specification itself, only its
* intent. We purposely leave _tolower() and _toupper() undocumented to
* discourage their use.
*
* XXX isascii() and toascii() should similarly be undocumented.
*/
#define _tolower(c) __tolower(c)
#define _toupper(c) __toupper(c)
#define isascii(c) (((c) & ~0x7F) == 0)
#define toascii(c) ((c) & 0x7F)
#endif
#if __BSD_VISIBLE
#define digittoint(c) __maskrune((c), 0xFF)
#define isblank(c) __istype((c), _CTYPE_B)
#define ishexnumber(c) __istype((c), _CTYPE_X)
#define isideogram(c) __istype((c), _CTYPE_I)
#define isnumber(c) __istype((c), _CTYPE_D)
#define isphonogram(c) __istype((c), _CTYPE_Q)
#define isrune(c) __istype((c), 0xFFFFFF00L)
#define isspecial(c) __istype((c), _CTYPE_T)
#endif
/* See comments in <sys/_types.h> about __ct_rune_t. */
__BEGIN_DECLS
unsigned long ___runetype(__ct_rune_t);
__ct_rune_t ___tolower(__ct_rune_t);
__ct_rune_t ___toupper(__ct_rune_t);
__END_DECLS
/*
* _EXTERNALIZE_CTYPE_INLINES_ is defined in locale/nomacros.c to tell us
* to generate code for extern versions of all our inline functions.
*/
#ifdef _EXTERNALIZE_CTYPE_INLINES_
#define _USE_CTYPE_INLINE_
#define static
#define __inline
#endif
/*
* <runetype.h> brings namespace pollution (struct member names). This prevents
* us from using the inline optimizations in the more strict __POSIX_VISIBLE and
* __XSI_VISIBLE namespaces. To fix this properly would require that we rename
* member names of long-standing structs, or something equally evil.
*/
#if !__BSD_VISIBLE && !defined(_USE_CTYPE_INLINE_) && \
!defined(_DONT_USE_CTYPE_INLINE_)
#define _DONT_USE_CTYPE_INLINE_
#endif
/*
* Use inline functions if we are allowed to and the compiler supports them.
*/
#if !defined(_DONT_USE_CTYPE_INLINE_) && \
(defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus))
#include <runetype.h>
static __inline int
__maskrune(__ct_rune_t _c, unsigned long _f)
{
return ((_c < 0 || _c >= _CACHED_RUNES) ? ___runetype(_c) :
_CurrentRuneLocale->runetype[_c]) & _f;
}
static __inline int
__istype(__ct_rune_t _c, unsigned long _f)
{
return (!!__maskrune(_c, _f));
}
static __inline int
__isctype(__ct_rune_t _c, unsigned long _f)
{
return (_c < 0 || _c >= _CACHED_RUNES) ? 0 :
!!(_DefaultRuneLocale.runetype[_c] & _f);
}
static __inline __ct_rune_t
__toupper(__ct_rune_t _c)
{
return (_c < 0 || _c >= _CACHED_RUNES) ? ___toupper(_c) :
_CurrentRuneLocale->mapupper[_c];
}
static __inline __ct_rune_t
__tolower(__ct_rune_t _c)
{
return (_c < 0 || _c >= _CACHED_RUNES) ? ___tolower(_c) :
_CurrentRuneLocale->maplower[_c];
}
#else /* not using inlines */
__BEGIN_DECLS
int __maskrune(__ct_rune_t, unsigned long);
int __istype(__ct_rune_t, unsigned long);
int __isctype(__ct_rune_t, unsigned long);
__ct_rune_t __toupper(__ct_rune_t);
__ct_rune_t __tolower(__ct_rune_t);
__END_DECLS
#endif /* using inlines */
#endif /* !_CTYPE_H_ */
+2 -4
View File
@@ -54,6 +54,8 @@
#if __BSD_VISIBLE
#include <sys/_null.h>
/* definitions for library routines operating on directories. */
#define DIRBLKSIZ 1024
@@ -81,10 +83,6 @@ typedef struct _dirdesc {
#define DTF_REWIND 0x0004 /* rewind after reading union stack */
#define __DTF_READALL 0x0008 /* everything has been read */
#ifndef NULL
#define NULL 0
#endif
#else /* !__BSD_VISIBLE */
typedef void * DIR;
+2 -4
View File
@@ -37,6 +37,8 @@
#ifndef _LOCALE_H_
#define _LOCALE_H_
#include <sys/_null.h>
struct lconv {
char *decimal_point;
char *thousands_sep;
@@ -64,10 +66,6 @@ struct lconv {
char int_n_sign_posn;
};
#ifndef NULL
#define NULL 0
#endif
#define LC_ALL 0
#define LC_COLLATE 1
#define LC_CTYPE 2
+3 -2
View File
@@ -46,8 +46,9 @@ enum nss_status {
NSS_STATUS_RETURN
};
#define __nss_compat_result(rv) \
((rv == NSS_STATUS_TRYAGAIN) ? NS_TRYAGAIN : \
#define __nss_compat_result(rv, err) \
((rv == NSS_STATUS_TRYAGAIN && err == ERANGE) ? NS_RETURN : \
(rv == NSS_STATUS_TRYAGAIN) ? NS_TRYAGAIN : \
(rv == NSS_STATUS_UNAVAIL) ? NS_UNAVAIL : \
(rv == NSS_STATUS_NOTFOUND) ? NS_NOTFOUND : \
(rv == NSS_STATUS_SUCCESS) ? NS_SUCCESS : \
+1 -3
View File
@@ -40,6 +40,7 @@
#define _RPC_TYPES_H
#include <sys/types.h>
#include <sys/_null.h>
typedef int32_t bool_t;
typedef int32_t enum_t;
@@ -59,9 +60,6 @@ typedef int32_t rpc_inline_t;
#ifndef TRUE
# define TRUE (1)
#endif
#ifndef NULL
# define NULL 0
#endif
#define mem_alloc(bsize) calloc(1, bsize)
#define mem_free(ptr, bsize) free(ptr)
+1 -4
View File
@@ -39,6 +39,7 @@
#define _STDDEF_H_
#include <sys/cdefs.h>
#include <sys/_null.h>
#include <sys/_types.h>
typedef __ptrdiff_t ptrdiff_t;
@@ -62,10 +63,6 @@ typedef __wchar_t wchar_t;
#endif
#endif
#ifndef NULL
#define NULL 0
#endif
#define offsetof(type, member) __offsetof(type, member)
#endif /* _STDDEF_H_ */
+1 -4
View File
@@ -41,6 +41,7 @@
#define _STDIO_H_
#include <sys/cdefs.h>
#include <sys/_null.h>
#include <sys/_types.h>
typedef __off_t fpos_t;
@@ -57,10 +58,6 @@ typedef __va_list va_list;
#endif
#endif
#ifndef NULL
#define NULL 0
#endif
#define _FSTDIO /* Define for new stdio with functions. */
/*
+1 -4
View File
@@ -38,6 +38,7 @@
#define _STDLIB_H_
#include <sys/cdefs.h>
#include <sys/_null.h>
#include <sys/_types.h>
#if __BSD_VISIBLE
@@ -69,10 +70,6 @@ typedef struct {
long rem;
} ldiv_t;
#ifndef NULL
#define NULL 0
#endif
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
+1 -4
View File
@@ -38,6 +38,7 @@
#define _STRING_H_
#include <sys/cdefs.h>
#include <sys/_null.h>
#include <sys/_types.h>
/*
@@ -53,10 +54,6 @@ typedef __size_t size_t;
#define _SIZE_T_DECLARED
#endif
#ifndef NULL
#define NULL 0
#endif
__BEGIN_DECLS
#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
void *memccpy(void * __restrict, const void * __restrict, int, size_t);
+1 -4
View File
@@ -46,6 +46,7 @@
#define _TIME_H_
#include <sys/cdefs.h>
#include <sys/_null.h>
#include <sys/_types.h>
#if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
@@ -59,10 +60,6 @@
/* Frequency of the clock ticks reported by clock(). */
#define CLOCKS_PER_SEC 128
#ifndef NULL
#define NULL 0
#endif
#ifndef _CLOCK_T_DECLARED
typedef __clock_t clock_t;
#define _CLOCK_T_DECLARED
+1 -4
View File
@@ -40,6 +40,7 @@
#include <sys/cdefs.h>
#include <sys/types.h> /* XXX adds too much pollution. */
#include <sys/unistd.h>
#include <sys/_null.h>
#include <sys/_types.h>
#ifndef _GID_T_DECLARED
@@ -81,10 +82,6 @@ typedef __useconds_t useconds_t;
#define STDOUT_FILENO 1 /* standard output file descriptor */
#define STDERR_FILENO 2 /* standard error file descriptor */
#ifndef NULL
#define NULL 0 /* null pointer constant */
#endif
#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
#define F_ULOCK 0 /* unlock locked section */
#define F_LOCK 1 /* lock a section for exclusive use */
+1 -4
View File
@@ -68,13 +68,10 @@
#define _WCHAR_H_
#include <sys/cdefs.h>
#include <sys/_null.h>
#include <sys/_types.h>
#include <machine/_limits.h>
#ifndef NULL
#define NULL 0
#endif
#ifndef _MBSTATE_T_DECLARED
typedef __mbstate_t mbstate_t;
#define _MBSTATE_T_DECLARED
File diff suppressed because it is too large. Load diff
-137
View File
@@ -1,137 +0,0 @@
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)fts.h 8.3 (Berkeley) 8/14/94
* $FreeBSD$
*/
#ifndef _FTS_H_
#define _FTS_H_
typedef struct {
struct _ftsent *fts_cur; /* current node */
struct _ftsent *fts_child; /* linked list of children */
struct _ftsent **fts_array; /* sort array */
dev_t fts_dev; /* starting device # */
char *fts_path; /* path for this descent */
int fts_rfd; /* fd for root */
int fts_pathlen; /* sizeof(path) */
int fts_nitems; /* elements in the sort array */
int (*fts_compar) /* compare function */
(const struct _ftsent * const *, const struct _ftsent * const *);
#define FTS_COMFOLLOW 0x001 /* follow command line symlinks */
#define FTS_LOGICAL 0x002 /* logical walk */
#define FTS_NOCHDIR 0x004 /* don't change directories */
#define FTS_NOSTAT 0x008 /* don't get stat info */
#define FTS_PHYSICAL 0x010 /* physical walk */
#define FTS_SEEDOT 0x020 /* return dot and dot-dot */
#define FTS_XDEV 0x040 /* don't cross devices */
#define FTS_WHITEOUT 0x080 /* return whiteout information */
#define FTS_OPTIONMASK 0x0ff /* valid user option mask */
#define FTS_NAMEONLY 0x100 /* (private) child names only */
#define FTS_STOP 0x200 /* (private) unrecoverable error */
int fts_options; /* fts_open options, global flags */
void *fts_clientptr; /* thunk for sort function */
} FTS;
typedef struct _ftsent {
struct _ftsent *fts_cycle; /* cycle node */
struct _ftsent *fts_parent; /* parent directory */
struct _ftsent *fts_link; /* next file in directory */
long fts_number; /* local numeric value */
void *fts_pointer; /* local address value */
char *fts_accpath; /* access path */
char *fts_path; /* root path */
int fts_errno; /* errno for this node */
int fts_symfd; /* fd for symlink */
u_short fts_pathlen; /* strlen(fts_path) */
u_short fts_namelen; /* strlen(fts_name) */
ino_t fts_ino; /* inode */
dev_t fts_dev; /* device */
nlink_t fts_nlink; /* link count */
#define FTS_ROOTPARENTLEVEL -1
#define FTS_ROOTLEVEL 0
short fts_level; /* depth (-1 to N) */
#define FTS_D 1 /* preorder directory */
#define FTS_DC 2 /* directory that causes cycles */
#define FTS_DEFAULT 3 /* none of the above */
#define FTS_DNR 4 /* unreadable directory */
#define FTS_DOT 5 /* dot or dot-dot */
#define FTS_DP 6 /* postorder directory */
#define FTS_ERR 7 /* error; errno is set */
#define FTS_F 8 /* regular file */
#define FTS_INIT 9 /* initialized only */
#define FTS_NS 10 /* stat(2) failed */
#define FTS_NSOK 11 /* no stat(2) requested */
#define FTS_SL 12 /* symbolic link */
#define FTS_SLNONE 13 /* symbolic link without target */
#define FTS_W 14 /* whiteout object */
u_short fts_info; /* user flags for FTSENT structure */
#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */
#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */
#define FTS_ISW 0x04 /* this is a whiteout object */
u_short fts_flags; /* private flags for FTSENT structure */
#define FTS_AGAIN 1 /* read node again */
#define FTS_FOLLOW 2 /* follow symbolic link */
#define FTS_NOINSTR 3 /* no instructions */
#define FTS_SKIP 4 /* discard node */
u_short fts_instr; /* fts_set() instructions */
struct stat *fts_statp; /* stat(2) information */
char *fts_name; /* file name */
FTS *fts_fts; /* back pointer to main FTS */
} FTSENT;
#include <sys/cdefs.h>
__BEGIN_DECLS
FTSENT *fts_children(FTS *, int);
int fts_close(FTS *);
void *fts_get_clientptr(FTS *);
#define fts_get_clientptr(fts) ((fts)->fts_clientptr)
FTS *fts_get_stream(FTSENT *);
#define fts_get_stream(ftsent) ((ftsent)->fts_fts)
FTS *fts_open(char * const *, int,
int (*)(const FTSENT * const *, const FTSENT * const *));
FTSENT *fts_read(FTS *);
int fts_set(FTS *, FTSENT *, int);
void fts_set_clientptr(FTS *, void *);
__END_DECLS
#endif /* !_FTS_H_ */
-357
View File
@@ -1,357 +0,0 @@
/*
* Copyright (C) 2000 Jason Evans <jasone@freebsd.org>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice(s), this list of conditions and the following disclaimer as
* the first lines of this file unmodified other than the possible
* addition of one or more copyright notices.
* 2. Redistributions in binary form must reproduce the above copyright
* notice(s), this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#include "namespace.h"
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <semaphore.h>
#include <stdarg.h>
#include <pthread.h>
#include <sys/queue.h>
#include <_semaphore.h>
#include "un-namespace.h"
#define _SEM_CHECK_VALIDITY(sem) \
if ((*(sem))->magic != SEM_MAGIC) { \
errno = EINVAL; \
retval = -1; \
goto RETURN; \
}
static sem_t sem_alloc(unsigned int value, semid_t semid, int system_sem);
static void sem_free(sem_t sem);
static LIST_HEAD(, sem) named_sems = LIST_HEAD_INITIALIZER(&named_sems);
static pthread_mutex_t named_sems_mtx = PTHREAD_MUTEX_INITIALIZER;
static void
sem_free(sem_t sem)
{
_pthread_mutex_destroy(&sem->lock);
_pthread_cond_destroy(&sem->gtzero);
sem->magic = 0;
free(sem);
}
static sem_t
sem_alloc(unsigned int value, semid_t semid, int system_sem)
{
sem_t sem;
if (value > SEM_VALUE_MAX) {
errno = EINVAL;
return (NULL);
}
sem = (sem_t)malloc(sizeof(struct sem));
if (sem == NULL) {
errno = ENOSPC;
return (NULL);
}
/*
* Initialize the semaphore.
*/
if (_pthread_mutex_init(&sem->lock, NULL) != 0) {
free(sem);
errno = ENOSPC;
return (NULL);
}
if (_pthread_cond_init(&sem->gtzero, NULL) != 0) {
_pthread_mutex_destroy(&sem->lock);
free(sem);
errno = ENOSPC;
return (NULL);
}
sem->count = (u_int32_t)value;
sem->nwaiters = 0;
sem->magic = SEM_MAGIC;
sem->semid = semid;
sem->syssem = system_sem;
return (sem);
}
int
sem_init(sem_t *sem, int pshared, unsigned int value)
{
int retval, got_system_sem;
semid_t semid;
got_system_sem = 0;
semid = SEM_USER;
/*
* Range check the arguments.
*/
if (pshared != 0) {
retval = ksem_init(&semid, value);
if (retval == -1)
goto RETURN;
got_system_sem = 1;
}
(*sem) = sem_alloc(value, semid, got_system_sem);
if ((*sem) == NULL)
retval = -1;
else
retval = 0;
RETURN:
if (retval != 0 && got_system_sem)
ksem_destroy(semid);
return retval;
}
int
sem_destroy(sem_t *sem)
{
int retval;
_SEM_CHECK_VALIDITY(sem);
_pthread_mutex_lock(&(*sem)->lock);
/*
* If this is a system semaphore let the kernel track it otherwise
* make sure there are no waiters.
*/
if ((*sem)->syssem != 0) {
retval = ksem_destroy((*sem)->semid);
if (retval == -1) {
_pthread_mutex_unlock(&(*sem)->lock);
goto RETURN;
}
} else if ((*sem)->nwaiters > 0) {
_pthread_mutex_unlock(&(*sem)->lock);
errno = EBUSY;
retval = -1;
goto RETURN;
}
_pthread_mutex_unlock(&(*sem)->lock);
sem_free(*sem);
retval = 0;
RETURN:
return retval;
}
sem_t *
sem_open(const char *name, int oflag, ...)
{
sem_t *sem;
sem_t s;
semid_t semid;
mode_t mode;
unsigned int value;
mode = 0;
value = 0;
if ((oflag & O_CREAT) != 0) {
va_list ap;
va_start(ap, oflag);
mode = va_arg(ap, int);
value = va_arg(ap, unsigned int);
va_end(ap);
}
/*
* we can be lazy and let the kernel handle the "oflag",
* we'll just merge duplicate IDs into our list.
*/
if (ksem_open(&semid, name, oflag, mode, value) == -1)
return (SEM_FAILED);
/*
* search for a duplicate ID, we must return the same sem_t *
* if we locate one.
*/
_pthread_mutex_lock(&named_sems_mtx);
LIST_FOREACH(s, &named_sems, entry) {
if (s->semid == semid) {
_pthread_mutex_unlock(&named_sems_mtx);
return (s->backpointer);
}
}
sem = (sem_t *)malloc(sizeof(*sem));
if (sem == NULL)
goto err;
*sem = sem_alloc(value, semid, 1);
if ((*sem) == NULL)
goto err;
LIST_INSERT_HEAD(&named_sems, *sem, entry);
(*sem)->backpointer = sem;
_pthread_mutex_unlock(&named_sems_mtx);
return (sem);
err:
_pthread_mutex_unlock(&named_sems_mtx);
ksem_close(semid);
if (sem != NULL) {
if (*sem != NULL)
sem_free(*sem);
else
errno = ENOSPC;
free(sem);
} else {
errno = ENOSPC;
}
return (SEM_FAILED);
}
int
sem_close(sem_t *sem)
{
if ((*sem)->syssem == 0) {
errno = EINVAL;
return (-1);
}
_pthread_mutex_lock(&named_sems_mtx);
if (ksem_close((*sem)->semid) == -1) {
_pthread_mutex_unlock(&named_sems_mtx);
return (-1);
}
LIST_REMOVE((*sem), entry);
_pthread_mutex_unlock(&named_sems_mtx);
sem_free(*sem);
free(sem);
return (0);
}
int
sem_unlink(const char *name)
{
return (ksem_unlink(name));
}
int
sem_wait(sem_t *sem)
{
int retval;
_SEM_CHECK_VALIDITY(sem);
if ((*sem)->syssem != 0) {
retval = ksem_wait((*sem)->semid);
goto RETURN;
}
_pthread_mutex_lock(&(*sem)->lock);
while ((*sem)->count == 0) {
(*sem)->nwaiters++;
_pthread_cond_wait(&(*sem)->gtzero, &(*sem)->lock);
(*sem)->nwaiters--;
}
(*sem)->count--;
_pthread_mutex_unlock(&(*sem)->lock);
retval = 0;
RETURN:
return retval;
}
int
sem_trywait(sem_t *sem)
{
int retval;
_SEM_CHECK_VALIDITY(sem);
if ((*sem)->syssem != 0) {
retval = ksem_trywait((*sem)->semid);
goto RETURN;
}
_pthread_mutex_lock(&(*sem)->lock);
if ((*sem)->count > 0) {
(*sem)->count--;
retval = 0;
} else {
errno = EAGAIN;
retval = -1;
}
_pthread_mutex_unlock(&(*sem)->lock);
RETURN:
return retval;
}
int
sem_post(sem_t *sem)
{
int retval;
_SEM_CHECK_VALIDITY(sem);
if ((*sem)->syssem != 0) {
retval = ksem_post((*sem)->semid);
goto RETURN;
}
_pthread_mutex_lock(&(*sem)->lock);
(*sem)->count++;
if ((*sem)->nwaiters > 0)
_pthread_cond_signal(&(*sem)->gtzero);
_pthread_mutex_unlock(&(*sem)->lock);
retval = 0;
RETURN:
return retval;
}
int
sem_getvalue(sem_t * __restrict sem, int * __restrict sval)
{
int retval;
_SEM_CHECK_VALIDITY(sem);
if ((*sem)->syssem != 0) {
retval = ksem_getvalue((*sem)->semid, sval);
goto RETURN;
}
_pthread_mutex_lock(&(*sem)->lock);
*sval = (int)(*sem)->count;
_pthread_mutex_unlock(&(*sem)->lock);
retval = 0;
RETURN:
return retval;
}
-84
View File
@@ -1,84 +0,0 @@
.\" Copyright (C) 2000 Jason Evans <[email protected]>.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice(s), this list of conditions and the following disclaimer as
.\" the first lines of this file unmodified other than the possible
.\" addition of one or more copyright notices.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice(s), this list of conditions and the following disclaimer in
.\" the documentation and/or other materials provided with the
.\" distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD$
.Dd February 15, 2000
.Dt SEM_DESTROY 3
.Os
.Sh NAME
.Nm sem_destroy
.Nd destroy an unnamed semaphore
.Sh LIBRARY
.Lb libc_r
.Sh SYNOPSIS
.In semaphore.h
.Ft int
.Fn sem_destroy "sem_t *sem"
.Sh DESCRIPTION
The
.Fn sem_destroy
function destroys the unnamed semaphore pointed to by
.Fa sem .
After a successful call to
.Fn sem_destroy ,
.Fa sem
is unusable until re-initialized by another call to
.Fn sem_init .
.Sh RETURN VALUES
.Rv -std sem_destroy
.Sh ERRORS
The
.Fn sem_destroy
function will fail if:
.Bl -tag -width Er
.It Bq Er EINVAL
.Fa sem
points to an invalid semaphore.
.It Bq Er EBUSY
There are currently threads blocked on the semaphore that
.Fa sem
points to.
.El
.Sh SEE ALSO
.Xr sem_init 3 ,
.Xr sem 4
.Sh STANDARDS
The
.Fn sem_destroy
function conforms to
.St -p1003.1-96 .
.Pp
POSIX does not define the behavior of
.Fn sem_destroy
if called while there are threads blocked on
.Fa sem ,
but this implementation is guaranteed to return -1 and set
.Va errno
to
.Er EBUSY
if there are threads blocked on
.Fa sem .
-76
View File
@@ -1,76 +0,0 @@
.\" Copyright (C) 2000 Jason Evans <[email protected]>.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice(s), this list of conditions and the following disclaimer as
.\" the first lines of this file unmodified other than the possible
.\" addition of one or more copyright notices.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice(s), this list of conditions and the following disclaimer in
.\" the documentation and/or other materials provided with the
.\" distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD$
.Dd February 15, 2000
.Dt SEM_GETVALUE 3
.Os
.Sh NAME
.Nm sem_getvalue
.Nd get the value of a semaphore
.Sh LIBRARY
.Lb libc_r
.Sh SYNOPSIS
.In semaphore.h
.Ft int
.Fn sem_getvalue "sem_t * restrict sem" "int * restrict sval"
.Sh DESCRIPTION
The
.Fn sem_getvalue
function sets the variable pointed to by
.Fa sval
to the current value of the semaphore pointed to by
.Fa sem ,
as of the time that the call to
.Fn sem_getvalue
is actually run.
.Sh RETURN VALUES
.Rv -std sem_getvalue
.Sh ERRORS
The
.Fn sem_getvalue
function will fail if:
.Bl -tag -width Er
.It Bq Er EINVAL
.Fa sem
points to an invalid semaphore.
.El
.Sh SEE ALSO
.Xr sem_post 3 ,
.Xr sem_trywait 3 ,
.Xr sem_wait 3 ,
.Xr sem 4
.Sh STANDARDS
The
.Fn sem_getvalue
function conforms to
.St -p1003.1-96 .
.Pp
The value of the semaphore is never negative, even if there are threads blocked
on the semaphore. POSIX is somewhat ambiguous in its wording with regard to
what the value of the semaphore should be if there are blocked waiting threads,
but this behavior is conformant, given the wording of the specification.
-102
View File
@@ -1,102 +0,0 @@
.\" Copyright (C) 2000 Jason Evans <[email protected]>.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice(s), this list of conditions and the following disclaimer as
.\" the first lines of this file unmodified other than the possible
.\" addition of one or more copyright notices.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice(s), this list of conditions and the following disclaimer in
.\" the documentation and/or other materials provided with the
.\" distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD$
.Dd February 15, 2000
.Dt SEM_INIT 3
.Os
.Sh NAME
.Nm sem_init
.Nd initialize an unnamed semaphore
.Sh LIBRARY
.Lb libc_r
.Sh SYNOPSIS
.In semaphore.h
.Ft int
.Fn sem_init "sem_t *sem" "int pshared" "unsigned int value"
.Sh DESCRIPTION
The
.Fn sem_init
function initializes the unnamed semaphore pointed to by
.Fa sem
to have the value
.Fa value .
A non-zero value for
.Fa pshared
specifies a shared semaphore that can be used by multiple processes, which this
implementation is not capable of.
.Pp
Following a successful call to
.Fn sem_init ,
.Fa sem
can be used as an argument in subsequent calls to
.Xr sem_wait 3 ,
.Xr sem_trywait 3 ,
.Xr sem_post 3 ,
and
.Xr sem_destroy 3 .
The
.Fa sem
argument is no longer valid after a successful call to
.Xr sem_destroy 3 .
.Sh RETURN VALUES
.Rv -std sem_init
.Sh ERRORS
The
.Fn sem_init
function will fail if:
.Bl -tag -width Er
.It Bq Er EINVAL
.Fa value
exceeds SEM_VALUE_MAX.
.It Bq Er ENOSPC
Memory allocation error.
.It Bq Er EPERM
Unable to initialize a shared semaphore.
.El
.Sh SEE ALSO
.Xr sem_destroy 3 ,
.Xr sem_post 3 ,
.Xr sem_trywait 3 ,
.Xr sem_wait 3 ,
.Xr sem 4
.Sh STANDARDS
The
.Fn sem_init
function conforms to
.St -p1003.1-96 .
.Pp
This implementation does not support shared semaphores, and reports this fact
by setting
.Va errno
to
.Er EPERM .
This is perhaps a stretch of the intention of POSIX, but is
compliant, with the caveat that
.Fn sem_init
always reports a permissions error when an attempt to create a shared semaphore
is made.
-227
View File
@@ -1,227 +0,0 @@
.\" Copyright (C) 2000 Jason Evans <[email protected]>.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice(s), this list of conditions and the following disclaimer as
.\" the first lines of this file unmodified other than the possible
.\" addition of one or more copyright notices.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice(s), this list of conditions and the following disclaimer in
.\" the documentation and/or other materials provided with the
.\" distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD$
.Dd January 15, 2003
.Dt SEM_OPEN 3
.Os
.Sh NAME
.Nm sem_open ,
.Nm sem_close ,
.Nm sem_unlink
.Nd named semaphore operations
.Sh LIBRARY
.Lb libc_r
.Sh SYNOPSIS
.In semaphore.h
.Ft sem_t *
.Fn sem_open "const char *name" "int oflag" "..."
.Ft int
.Fn sem_close "sem_t *sem"
.Ft int
.Fn sem_unlink "const char *name"
.Sh DESCRIPTION
The
.Fn sem_open
function creates or opens the named semaphore specified by
.Fa name .
The returned semaphore may be used in subsequent calls to
.Fn sem_getvalue ,
.Fn sem_wait ,
.Fn sem_trywait ,
.Fn sem_post
and
.Fn sem_close .
.Pp
The following bits may be set in the
.Fa oflag
argument:
.Bl -tag -width ".Dv O_CREAT"
.It Dv O_CREAT
Create the semaphore if it does not already exist.
.Pp
The third argument to the call to
.Fn sem_open
must be of type
.Vt mode_t
and specifies the mode for the semaphore.
Only the
.Dv S_IWUSR ,
.Dv S_IWGRP ,
and
.Dv S_IWOTH
bits are examined;
it is not possible to grant only
.Dq read
permission on a semaphore.
The mode is modified according to the process's file creation
mask; see
.Xr umask 2 .
.Pp
The fourth argument must be an
.Vt "unsigned int"
and specifies the initial value for the semaphore,
and must be no greater than
.Dv SEM_VALUE_MAX .
.It Dv O_EXCL
Create the semaphore if it does not exist.
If the semaphore already exists,
.Fn sem_open
will fail.
This flag is ignored unless
.Dv O_CREAT
is also specified.
.El
.Pp
The
.Fn sem_close
function closes a named semaphore that was opened by a call to
.Fn sem_open .
.Pp
The
.Fn sem_unlink
function removes the semaphore named
.Fa name .
Resources allocated to the semaphore are only deallocated when all
processes that have the semaphore open close it.
.Sh RETURN VALUES
If successful,
the
.Fn sem_open
function returns the address of the opened semaphore.
If the same
.Fa name
argument is given to multiple calls to
.Fn sem_open
by the same process without an intervening call to
.Fn sem_close ,
the same address is returned each time.
If the semaphore cannot be opened,
.Fn sem_open
returns
.Dv SEM_FAILED
and the global variable
.Va errno
is set to indicate the error.
.Pp
.Rv -std sem_close sem_unlink
.Sh ERRORS
The
.Fn sem_open
function will fail if:
.Bl -tag -width Er
.It Bq Er EACCES
The semaphore exists and the permissions specified by
.Fa oflag
at the time it was created deny access to the this process.
.It Bq Er EACCES
The semaphore does not exist, but permission to create it is denied.
.It Bq Er EEXIST
.Dv O_CREAT
and
.Dv O_EXCL
are set but the semaphore already exists.
.It Bq Er EINTR
The call was interrupted by a signal.
.It Bq Er EINVAL
The
.Fn sem_open
operation is not supported for the given
.Fa name .
.It Bq Er EINVAL
The
.Fa value
argument is greater than
.Dv SEM_VALUE_MAX .
.\"FreeBSD never returns EMFILE
.\".It Bq Er EMFILE
.\"Too many semaphores are in use by this process.
.It Bq Er ENAMETOOLONG
The
.Fa name
argument is too long.
.It Bq Er ENFILE
The system limit on semaphores has been reached.
.It Bq Er ENOENT
.Dv O_CREAT
is set but the named semaphore does not exist.
.It Bq Er ENOSPC
There is not enough space to create the semaphore.
.El
.Pp
The
.Fn sem_close
function will fail if:
.Bl -tag -width Er
.It Bq Er EINVAL
The
.Fa sem
argument is not a valid semaphore.
.El
.Pp
The
.Fn sem_unlink
function will fail if:
.Bl -tag -width Er
.It Bq Er EACCES
Permission is denied to unlink the semaphore.
.It Bq Er ENAMETOOLONG
The specified
.Fa name
is too long.
.It Bq Er ENOENT
The named semaphore does not exist.
.El
.Sh SEE ALSO
.Xr close 2 ,
.Xr open 2 ,
.Xr umask 2 ,
.Xr unlink 2 ,
.Xr sem_getvalue 3 ,
.Xr sem_post 3 ,
.Xr sem_trywait 3 ,
.Xr sem_wait 3 ,
.Xr sem 4
.Sh STANDARDS
The
.Fn sem_open ,
.Fn sem_close ,
and
.Fn sem_unlink
functions conform to
.St -p1003.1-96 .
.Sh HISTORY
Support for named semaphores first appeared in
.Fx 5.0 .
.Sh BUGS
This implementation places strict requirements on the value of
.Fa name :
it must begin with a slash
.Pq Ql / ,
contain no other slash characters,
and be less than 14 characters in length
not including the terminating null character.
-74
View File
@@ -1,74 +0,0 @@
.\" Copyright (C) 2000 Jason Evans <[email protected]>.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice(s), this list of conditions and the following disclaimer as
.\" the first lines of this file unmodified other than the possible
.\" addition of one or more copyright notices.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice(s), this list of conditions and the following disclaimer in
.\" the documentation and/or other materials provided with the
.\" distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD$
.Dd February 15, 2000
.Dt SEM_POST 3
.Os
.Sh NAME
.Nm sem_post
.Nd increment (unlock) a semaphore
.Sh LIBRARY
.Lb libc_r
.Sh SYNOPSIS
.In semaphore.h
.Ft int
.Fn sem_post "sem_t *sem"
.Sh DESCRIPTION
The
.Fn sem_post
function increments (unlocks) the semaphore pointed to by
.Fa sem .
If there are threads blocked on the semaphore when
.Fn sem_post
is called, then the highest priority thread that has been blocked the longest on
the semaphore will be allowed to return from
.Fn sem_wait .
.Pp
The
.Fn sem_post
function is signal-reentrant and may be called within signal handlers.
.Sh RETURN VALUES
.Rv -std sem_post
.Sh ERRORS
The
.Fn sem_post
function will fail if:
.Bl -tag -width Er
.It Bq Er EINVAL
.Fa sem
points to an invalid semaphore.
.El
.Sh SEE ALSO
.Xr sem_trywait 3 ,
.Xr sem_wait 3 ,
.Xr sem 4
.Sh STANDARDS
The
.Fn sem_post
function conforms to
.St -p1003.1-96 .
-89
View File
@@ -1,89 +0,0 @@
.\" Copyright (C) 2000 Jason Evans <[email protected]>.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice(s), this list of conditions and the following disclaimer as
.\" the first lines of this file unmodified other than the possible
.\" addition of one or more copyright notices.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice(s), this list of conditions and the following disclaimer in
.\" the documentation and/or other materials provided with the
.\" distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD$
.Dd February 15, 2000
.Dt SEM_WAIT 3
.Os
.Sh NAME
.Nm sem_wait ,
.Nm sem_trywait
.Nd decrement (lock) a semaphore
.Sh LIBRARY
.Lb libc_r
.Sh SYNOPSIS
.In semaphore.h
.Ft int
.Fn sem_wait "sem_t *sem"
.Ft int
.Fn sem_trywait "sem_t *sem"
.Sh DESCRIPTION
The
.Fn sem_wait
function decrements (locks) the semaphore pointed to by
.Fa sem ,
but blocks if the value of
.Fa sem
is zero, until the value is non-zero and the value can be decremented.
.Pp
The
.Fn sem_trywait
function decrements (locks) the semaphore pointed to by
.Fa sem
only if the value is non-zero. Otherwise, the semaphore is not decremented and
an error is returned.
.Sh RETURN VALUES
.Rv -std
.Sh ERRORS
The
.Fn sem_wait
and
.Fn sem_trywait
functions will fail if:
.Bl -tag -width Er
.It Bq Er EINVAL
.Fa sem
points to an invalid semaphore.
.El
.Pp
Additionally,
.Fn sem_trywait
will fail if:
.Bl -tag -width Er
.It Bq Er EAGAIN
The semaphore value was zero, and thus could not be decremented.
.El
.Sh SEE ALSO
.Xr sem_post 3 ,
.Xr sem 4
.Sh STANDARDS
The
.Fn sem_wait
and
.Fn sem_trywait
functions conform to
.St -p1003.1-96 .
+14
View File
@@ -71,6 +71,10 @@ extern size_t __emulated_wcrtomb(char * __restrict, wchar_t,
mbstate_t * __restrict ps);
extern rune_t __emulated_sgetrune(const char *, size_t, const char **);
extern int __emulated_sputrune(rune_t, char *, size_t, char **);
extern size_t _none_mbrtowc(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
extern size_t _none_wcrtomb(char * __restrict, wchar_t,
mbstate_t * __restrict);
static int __setrunelocale(const char *);
@@ -104,6 +108,10 @@ __setrunelocale(const char *encoding)
static char ctype_encoding[ENCODING_LEN + 1];
static _RuneLocale *CachedRuneLocale;
static int Cached__mb_cur_max;
static size_t (*Cached__mbrtowc)(wchar_t * __restrict,
const char * __restrict, size_t, mbstate_t * __restrict);
static size_t (*Cached__wcrtomb)(char * __restrict, wchar_t,
mbstate_t * __restrict);
/*
* The "C" and "POSIX" locale are always here.
@@ -111,6 +119,8 @@ __setrunelocale(const char *encoding)
if (strcmp(encoding, "C") == 0 || strcmp(encoding, "POSIX") == 0) {
_CurrentRuneLocale = &_DefaultRuneLocale;
__mb_cur_max = 1;
__mbrtowc = _none_mbrtowc;
__wcrtomb = _none_wcrtomb;
return (0);
}
@@ -121,6 +131,8 @@ __setrunelocale(const char *encoding)
strcmp(encoding, ctype_encoding) == 0) {
_CurrentRuneLocale = CachedRuneLocale;
__mb_cur_max = Cached__mb_cur_max;
__mbrtowc = Cached__mbrtowc;
__wcrtomb = Cached__wcrtomb;
return (0);
}
@@ -177,6 +189,8 @@ __setrunelocale(const char *encoding)
}
CachedRuneLocale = _CurrentRuneLocale;
Cached__mb_cur_max = __mb_cur_max;
Cached__mbrtowc = __mbrtowc;
Cached__wcrtomb = __wcrtomb;
(void)strcpy(ctype_encoding, encoding);
} else
free(rl);
+15 -8
View File
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
#include "namespace.h"
#include <sys/param.h>
#include <errno.h>
#include <nss.h>
#include <pthread.h>
#include <pthread_np.h>
@@ -96,9 +97,10 @@ __nss_compat_getgrnam_r(void *retval, void *mdata, va_list ap)
bufsize = va_arg(ap, size_t);
errnop = va_arg(ap, int *);
status = fn(name, grp, buffer, bufsize, errnop);
status = __nss_compat_result(status, *errnop);
if (status == NS_SUCCESS)
*(struct group **)retval = grp;
return (__nss_compat_result(status));
return (status);
}
@@ -120,9 +122,10 @@ __nss_compat_getgrgid_r(void *retval, void *mdata, va_list ap)
bufsize = va_arg(ap, size_t);
errnop = va_arg(ap, int *);
status = fn(gid, grp, buffer, bufsize, errnop);
status = __nss_compat_result(status, *errnop);
if (status == NS_SUCCESS)
*(struct group **)retval = grp;
return (__nss_compat_result(status));
return (status);
}
@@ -144,11 +147,12 @@ __nss_compat_getgrent_r(void *retval, void *mdata, va_list ap)
bufsize = va_arg(ap, size_t);
errnop = va_arg(ap, int *);
status = fn(grp, buffer, bufsize, errnop);
status = __nss_compat_result(status, *errnop);
if (status == NS_SUCCESS)
*(struct group **)retval = grp;
else
else if (status != NS_RETURN)
SET_TERMINATOR(group, &terminator);
return (__nss_compat_result(status));
return (status);
}
@@ -194,9 +198,10 @@ __nss_compat_getpwnam_r(void *retval, void *mdata, va_list ap)
bufsize = va_arg(ap, size_t);
errnop = va_arg(ap, int *);
status = fn(name, pwd, buffer, bufsize, errnop);
status = __nss_compat_result(status, *errnop);
if (status == NS_SUCCESS)
*(struct passwd **)retval = pwd;
return (__nss_compat_result(status));
return (status);
}
@@ -218,9 +223,10 @@ __nss_compat_getpwuid_r(void *retval, void *mdata, va_list ap)
bufsize = va_arg(ap, size_t);
errnop = va_arg(ap, int *);
status = fn(uid, pwd, buffer, bufsize, errnop);
status = __nss_compat_result(status, *errnop);
if (status == NS_SUCCESS)
*(struct passwd **)retval = pwd;
return (__nss_compat_result(status));
return (status);
}
@@ -242,11 +248,12 @@ __nss_compat_getpwent_r(void *retval, void *mdata, va_list ap)
bufsize = va_arg(ap, size_t);
errnop = va_arg(ap, int *);
status = fn(pwd, buffer, bufsize, errnop);
status = __nss_compat_result(status, *errnop);
if (status == NS_SUCCESS)
*(struct passwd **)retval = pwd;
else
else if (status != NS_RETURN)
SET_TERMINATOR(passwd, &terminator);
return (__nss_compat_result(status));
return (status);
}
-87
View File
@@ -1,87 +0,0 @@
.\" Copyright (c) 2002 Networks Associates Technology, Inc.
.\" All rights reserved.
.\"
.\" This software was developed for the FreeBSD Project by Chris
.\" Costello at Safeport Network Services and NAI Labs, the Security
.\" Research Division of Network Associates, Inc. under DARPA/SPAWAR
.\" contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS
.\" research program.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd January 9, 2002
.Dt MAC_IS_PRESENT_NP 3
.Os
.Sh NAME
.Nm mac_is_present_np
.Nd report whether the running system has MAC support
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In sys/mac.h
.Ft int
.Fn mac_is_present "const char *policyname"
.Sh DESCRIPTION
The
.Fn mac_is_present_np
function determines whether the currently-running kernel supports MAC for
a given policy or not.
If
.Fa policyname
is
.No non- Ns Dv NULL ,
the presence of the named policy
(e.g.\&
.Dq Li biba ,
.Dq Li mls ,
.Dq Li te )
is checked, otherwise the presence of any MAC policies at all is checked.
.Sh RETURN VALUES
If the system supports the given MAC policy, the value 1 is returned.
If the specified MAC policy is not supported, the value 0 is returned.
If an error occurs, the value \-1 is returned.
.Sh ERRORS
.Bl -tag -width Er
.It Bq Er EINVAL
The value of
.Fa policyname
is not valid.
.It Bq Er ENOMEM
Insufficient memory was available to allocate internal storage.
.El
.Sh SEE ALSO
.Xr mac 3 ,
.Xr mac_free 3 ,
.Xr mac_get 3 ,
.Xr mac_prepare 3 ,
.Xr mac_set 3 ,
.Xr mac_text 3 ,
.Xr mac 4 ,
.Xr mac 9
.Sh HISTORY
Support for Mandatory Access Control was introduced in
.Fx 5.0
as part of the
.Tn TrustedBSD
Project.
+2 -2
View File
@@ -223,7 +223,7 @@ static unsigned malloc_ninfo;
static struct pgfree free_list;
/* Abort(), user doesn't handle problems. */
static int malloc_abort = 1;
static int malloc_abort;
/* Are we trying to die ? */
static int suicide;
@@ -246,7 +246,7 @@ static int malloc_sysv;
static int malloc_zero;
/* junk fill ? */
static int malloc_junk = 1;
static int malloc_junk;
#ifdef HAS_UTRACE
-193
View File
@@ -1,193 +0,0 @@
.\"
.\" Copyright 2000 Massachusetts Institute of Technology
.\"
.\" Permission to use, copy, modify, and distribute this software and
.\" its documentation for any purpose and without fee is hereby
.\" granted, provided that both the above copyright notice and this
.\" permission notice appear in all copies, that both the above
.\" copyright notice and this permission notice appear in all
.\" supporting documentation, and that the name of M.I.T. not be used
.\" in advertising or publicity pertaining to distribution of the
.\" software without specific, written prior permission. M.I.T. makes
.\" no representations about the suitability of this software for any
.\" purpose. It is provided "as is" without express or implied
.\" warranty.
.\"
.\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
.\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
.\" SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd March 24, 2000
.Dt SHM_OPEN 3
.Os
.Sh NAME
.Nm shm_open
.Nd open or create a shared memory object
.Nm shm_unlink
.Nd remove a shared memory object
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In sys/types.h
.In sys/mman.h
.Ft int
.Fn shm_open "const char *path" "int flags" "mode_t mode"
.Ft int
.Fn shm_unlink "const char *path"
.Sh DESCRIPTION
The
.Fn shm_open
function opens (or optionally creates) a
.Tn POSIX
shared memory object named
.Fa path .
The
.Fn shm_unlink
function removes a shared memory object named
.Fa path .
.Pp
In the
.Fx
implementation,
.Tn POSIX
shared memory objects are implemented as ordinary files.
The
.Fn shm_open
and
.Fn shm_unlink
act as wrappers around the
.Xr open 2
and
.Xr unlink 2
routines, and
.Fa path ,
.Fa flags ,
and
.Fa mode
arguments are as specified for those functions.
The
.Fa flags
argument is checked to ensure that the access mode specified is not
.Dv O_WRONLY
(which is not defined for shared memory objects).
.Pp
In addition, the
.Fx
implementation causes
.Fn mmap
of a descriptor returned by
.Fn shm_open
to behave as if the
.Dv MAP_NOSYNC
flag had been specified to
.Xr mmap 2 .
(It does so by setting a special file flag using
.Xr fcntl 2 . )
.Pp
The
.Fn shm_unlink
function makes no effort to ensure that
.Fa path
refers to a shared memory object.
.Sh COMPATIBILITY
The
.Fa path
argument does not necessarily represent a pathname (although it does in this
and most other implementations).
Two processes opening the same
.Fa path
are guaranteed to access the same shared memory object if and only if
.Fa path
begins with a slash
.Pq Ql \&/
character.
.Pp
Only the
.Dv O_RDONLY ,
.Dv O_RDWR ,
.Dv O_CREAT ,
.Dv O_EXCL ,
and
.Dv O_TRUNC
flags may be used in portable programs.
.Pp
The result of using
.Xr open 2 ,
.Xr read 2 ,
or
.Xr write 2
on a shared memory object, or on the descriptor returned by
.Fn shm_open ,
is undefined.
It is also undefined whether the shared memory object itself, or its
contents, persist across reboots.
.Sh RETURN VALUES
If successful,
.Fn shm_open
returns a non-negative integer;
.Fn shm_unlink
returns zero.
Both functions return -1 on failure, and set
.Va errno
to indicate the error.
.Sh ERRORS
The
.Fn shm_open
and
.Fn shm_unlink
functions can fail with any error defined for
.Fn open
and
.Fn unlink ,
respectively. In addition, the following errors are defined for
.Fn shm_open :
.Bl -tag -width Er
.It Bq Er EINVAL
The object named by
.Fa path
is not a shared memory object
(i.e., it is not a regular file).
.It Bq Er EINVAL
The
.Fa flags
argument to
.Fn shm_open
specifies an access mode of
.Dv O_WRONLY .
.El
.Sh SEE ALSO
.Xr mmap 2 ,
.Xr munmap 2 ,
.Xr open 2 ,
.Xr unlink 2
.Sh STANDARDS
The
.Fn shm_open
and
.Fn shm_unlink
functions are believed to conform to
.St -p1003.1b-93 .
.Sh HISTORY
The
.Fn shm_open
and
.Fn shm_unlink
functions first appeared in
.Fx 4.3 .
.Sh AUTHORS
.An Garrett A. Wollman Aq [email protected]
(C library support and this manual page)
.Pp
.An Matthew Dillon Aq [email protected]
.Pq Dv MAP_NOSYNC
-86
View File
@@ -1,86 +0,0 @@
.\" Copyright (C) 2000 Jason Evans <[email protected]>.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice(s), this list of conditions and the following disclaimer as
.\" the first lines of this file unmodified other than the possible
.\" addition of one or more copyright notices.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice(s), this list of conditions and the following disclaimer in
.\" the documentation and/or other materials provided with the
.\" distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD$
.Dd April 27, 2000
.Dt SIGWAIT 3
.Os
.Sh NAME
.Nm sigwait
.Nd select a set of signals
.Sh LIBRARY
.Lb libc_r
.Sh SYNOPSIS
.In signal.h
.Ft int
.Fn sigwait "const sigset_t * restrict set" "int * restrict sig"
.Sh DESCRIPTION
The
.Fn sigwait
function selects a set of signals, specified by
.Fa set .
If none of the selected signals are pending,
.Fn sigwait
waits until one or more of the selected signals has been generated.
Then
.Fn sigwait
atomically clears one of the selected signals from the set of pending signals
for the process and sets the location pointed to by
.Fa sig
to the signal number that was cleared.
.Pp
The signals specified by
.Fa set
should be blocked at the time of the call to
.Fn sigwait .
.Sh RETURN VALUES
If successful,
.Fn sigwait
returns 0 and sets the location pointed to by
.Fa sig
to the cleared signal number.
Otherwise, an error number is returned.
.Sh ERRORS
The
.Fn sigwait
function will fail if:
.Bl -tag -width Er
.It Bq Er EINVAL
.Fa set
specifies one or more invalid signal numbers.
.El
.Sh SEE ALSO
.Xr sigaction 2 ,
.Xr sigpending 2 ,
.Xr sigsuspend 2 ,
.Xr pause 3 ,
.Xr pthread_sigmask 3
.Sh STANDARDS
The
.Fn sigwait
function conforms to
.St -p1003.1-96
+1 -1
View File
@@ -86,7 +86,7 @@ All_FreeBSD(struct disk *d, int force_all)
int type;
#ifdef PC98
type = 0x494;
type = 0xc494;
#else
type = 0xa5;
#endif
+4 -7
View File
@@ -121,6 +121,7 @@ write_pmbr(int fd, const struct disk *disk)
u_long nsects;
int error;
error = 0;
nsects = disk->media_size / disk->sector_size;
buffer = calloc(disk->sector_size, 1);
if (buffer == NULL)
@@ -153,6 +154,7 @@ read_gpt(int fd, const struct disk *disk, struct gpt_hdr *hdr,
size_t nsects, sz;
int error, i;
error = 0;
nsects = disk->gpt_size * sizeof(struct gpt_ent) / disk->sector_size;
nsects++;
sz = nsects * disk->sector_size;
@@ -191,7 +193,6 @@ read_gpt(int fd, const struct disk *disk, struct gpt_hdr *hdr,
uuid_create(&tbl[i].ent_uuid, NULL);
}
error = 0;
goto bail;
}
@@ -213,7 +214,6 @@ read_gpt(int fd, const struct disk *disk, struct gpt_hdr *hdr,
goto bail;
}
memcpy(&hdr[1], buffer, sizeof(struct gpt_hdr));
error = 0;
bail:
free(buffer);
@@ -231,6 +231,8 @@ update_gpt(int fd, const struct disk *disk, struct gpt_hdr *hdr,
size_t bufsz;
int error, idx, sav;
error = 0;
/*
* Save the entries of those chunks that have an index. They are
* the ones that exist on disk already.
@@ -358,7 +360,6 @@ update_gpt(int fd, const struct disk *disk, struct gpt_hdr *hdr,
error = (errno) ? errno : EAGAIN;
goto bail;
}
error = 0;
bail:
free(buffer);
@@ -411,10 +412,6 @@ Write_Disk(const struct disk *disk)
* Update and write the in-memory copy of the GPT.
*/
error = update_gpt(fd, disk, hdr, tbl);
if (error)
goto bail;
return (0);
bail:
close(fd);
+1
View File
@@ -10,6 +10,7 @@ SHLIB_MAJOR= 1
MAN= kiconv.3
MLINKS+= kiconv.3 kiconv_add_xlat16_cspair.3 \
kiconv.3 kiconv_add_xlat16_cspairs.3 \
kiconv.3 kiconv_add_xlat16_table.3
CFLAGS+= -I${.CURDIR}/../../sys
+17
View File
@@ -30,6 +30,7 @@
.Os
.Sh NAME
.Nm kiconv_add_xlat16_cspair ,
.Nm kiconv_add_xlat16_cspairs ,
.Nm kiconv_add_xlat16_table
.Nd Kernel side iconv library
.Sh LIBRARY
@@ -43,6 +44,11 @@
.Fa "int flag"
.Fc
.Ft int
.Fo kiconv_add_xlat16_cspairs
.Fa "const char *foreigncode"
.Fa "const char *localcode"
.Fc
.Ft int
.Fo kiconv_add_xlat16_table
.Fa "const char *tocode"
.Fa "const char *fromcode"
@@ -92,6 +98,17 @@ or toupper
.Pp
A tolower/toupper conversion is limited to single-byte characters.
.Pp
.Fn kiconv_add_xlat16_cspairs
defines two conversion tables which are from
.Ar localcode
to
.Ar foreigncode
and from
.Ar foreigncode
to
.Ar localcode .
This conversion tables also contain both of tolower and toupper tables.
.Pp
.Fn kiconv_add_xlat16_table
defines a conversion table directly pointed by
.Ar data
+24
View File
@@ -113,6 +113,23 @@ kiconv_add_xlat16_cspair(const char *tocode, const char *fromcode, int flag)
return (-1);
}
int
kiconv_add_xlat16_cspairs(const char *foreigncode, const char *localcode)
{
int error;
error = kiconv_add_xlat16_cspair(foreigncode, localcode,
KICONV_FROM_LOWER | KICONV_FROM_UPPER);
if (error)
return (error);
error = kiconv_add_xlat16_cspair(localcode, foreigncode,
KICONV_LOWER | KICONV_UPPER);
if (error)
return (error);
return (0);
}
static struct xlat16_table
kiconv_xlat16_open(const char *tocode, const char *fromcode, int lcase)
{
@@ -371,4 +388,11 @@ kiconv_add_xlat16_cspair(const char *tocode, const char *fromcode, int flag)
return (-1);
}
int
kiconv_add_xlat16_cspairs(const char *tocode, const char *fromcode)
{
errno = EINVAL;
return (-1);
}
#endif /* PIC */
-53
View File
@@ -1,53 +0,0 @@
# $FreeBSD$
#
# All library objects contain FreeBSD revision strings by default; they may be
# excluded as a space-saving measure. To produce a library that does
# not contain these strings, add -DSTRIP_FBSDID (see <sys/cdefs.h>) to CFLAGS
# below. Note, there are no IDs for syscall stubs whose sources are generated.
# To included legacy CSRG sccsid strings, add -DLIBC_SCCS and -DSYSLIBC_SCCS
# (for system call stubs) to CFLAGS below. -DSYSLIBC_SCCS affects just the
# system call stubs.
LIB=kse
SHLIB_MAJOR= 1
CFLAGS+=-DPTHREAD_KERNEL
CFLAGS+=-I${.CURDIR}/../libc/include -I${.CURDIR}/thread \
-I${.CURDIR}/../../include
CFLAGS+=-I${.CURDIR}/arch/${MACHINE_ARCH}/include
CFLAGS+=-I${.CURDIR}/sys
CFLAGS+=-I${.CURDIR}/../../libexec/rtld-elf
CFLAGS+=-fno-builtin
# Uncomment this if you want libpthread to contain debug information for
# thread locking.
CFLAGS+=-D_LOCK_DEBUG
#CFLAGS+= -g
# Uncomment this if you want to build a 1:1 threading mode library
# however it is no longer strictly conformed to POSIX
# CFLAGS+=-DSYSTEM_SCOPE_ONLY
LDFLAGS= -Wl,--version-script=${.CURDIR}/pthread.map
# enable extra internal consistancy checks
CFLAGS+=-D_PTHREADS_INVARIANTS -Wall
PRECIOUSLIB= yes
.include "${.CURDIR}/arch/${MACHINE_ARCH}/Makefile.inc"
.include "${.CURDIR}/support/Makefile.inc"
.include "${.CURDIR}/sys/Makefile.inc"
.include "${.CURDIR}/thread/Makefile.inc"
.if !defined(NOLIBC_R)
.if ${MACHINE_ARCH} == "ia64"
SYMLINKS+=lib${LIB}.a ${LIBDIR}/libc_r.a
.if !defined(NOPIC)
SYMLINKS+=lib${LIB}.so ${SHLIBDIR}/libc_r.so
.endif
.if !defined(NOPROFILE)
SYMLINKS+=lib${LIB}_p.a ${LIBDIR}/libc_r_p.a
.endif
.endif
.endif
.include <bsd.lib.mk>
-5
View File
@@ -1,5 +0,0 @@
# $FreeBSD$
.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/${MACHINE_ARCH}
SRCS+= context.S enter_uts.S pthread_md.c
-210
View File
@@ -1,210 +0,0 @@
/*
* Copyright (c) 2003 Daniel Eischen <deischen@freebsd.org>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/*
* The following notes ("cheat sheet") was provided by Peter Wemm.
*
* scratch:
* rax (1st return)
* rcx (4th arg)
* rdx (3rd arg, 2nd return)
* rsi (2nd arg)
* rdi (1st arg)
* r8 (5th arg)
* r9 (6th arg)
* r10 (temp, static chain?)
* r11 (temp)
*
* preserved:
* rbx (base pointer)
* rsp (stack)
* rbp (frame)
* r12-r15 (general)
*
* calls:
* rdi 1
* rsi 2
* rdx 3
* rcx 4
* r8 5
* r9 6
*
* return:
* rax 1
* rdx 2
*
* This means:
* arg1 goes in %rdi, arg2 in %rsi, etc. return value is %rax (and
* secondary return, eg: pipe(2), in %rdx) %rcx,%rsi,%rdi etc are
* trashed by making a call to something. %rbx,%rbp,%r12-15 are the
* only registers preserved across a call. Note that unlike i386,
* %rsi and %rdi are scratch rather than preserved. FPU is
* different, args are in SSE registers rather than the x87 stack.
*
* Aside from the register calling conventions, amd64 can be treated
* very much like i386. Things like setjmp/longjmp etc were literal
* translations from i386 but with the register names updated, etc.
* The main gotcha is that FPU save/restore is in SSE format, which
* means a sparse 512 byte FPU context.
*/
/*
* Where do we define these?
*/
#define MC_SIZE 800 /* sizeof mcontext_t */
#define MC_LEN_OFFSET (25*8) /* offset to mc_len from mcontext */
#define MC_FPFMT_OFFSET (26*8) /* offset to mc_fpformat from mcontext */
#define MC_FPFMT_NODEV 0x10000
#define MC_OWNEDFP_OFFSET (27*8) /* offset to mc_ownedfp from mcontext */
#define MC_OWNEDFP_NONE 0x20000
#define MC_OWNEDFP_FPU 0x20001
#define MC_OWNEDFP_PCB 0x20002
#define MC_FPREGS_OFFSET (28*8) /* offset to FP registers */
#define MC_FP_CW_OFFSET (28*8) /* offset to FP control word */
#define MC_RDI (1 * 8)
#define MC_RSI (2 * 8)
#define MC_RDX (3 * 8)
#define MC_RCX (4 * 8)
#define MC_R8 (5 * 8)
#define MC_R9 (6 * 8)
#define MC_RAX (7 * 8)
#define MC_RBX (8 * 8)
#define MC_RBP (9 * 8)
#define MC_R10 (10 * 8)
#define MC_R11 (11 * 8)
#define MC_R12 (12 * 8)
#define MC_R13 (13 * 8)
#define MC_R14 (14 * 8)
#define MC_R15 (15 * 8)
#define MC_FLAGS (18 * 8)
#define MC_RIP (20 * 8)
#define MC_RFLAGS (22 * 8)
#define MC_RSP (23 * 8)
/*
* _amd64_ctx_save(mcontext_t *mcp)
*
* No values are saved to mc_trapno, mc_addr, mc_err, mc_cs, or mc_ss.
* For the FPU state, only the floating point control word is stored.
*/
ENTRY(_amd64_save_context)
cmpq $0, %rdi /* check for null pointer */
jne 1f
movq $-1, %rax
jmp 2f
1: movq %rdi, MC_RDI(%rdi)
movq %rsi, MC_RSI(%rdi)
movq %rdx, MC_RDX(%rdi)
movq %rcx, MC_RCX(%rdi)
movq %r8, MC_R8(%rdi)
movq %r9, MC_R9(%rdi)
movq $1, MC_RAX(%rdi) /* return 1 when restored */
movq %rbx, MC_RBX(%rdi)
movq %rbp, MC_RBP(%rdi)
movq %r10, MC_R10(%rdi)
movq %r11, MC_R11(%rdi)
movq %r12, MC_R12(%rdi)
movq %r13, MC_R13(%rdi)
movq %r14, MC_R14(%rdi)
movq %r15, MC_R15(%rdi)
movq (%rsp), %rax /* get return address */
movq %rax, MC_RIP(%rdi) /* save return address (%rip) */
pushfq /* get flags */
popq %rax
movq %rax, MC_RFLAGS(%rdi) /* save flags */
movq %rsp, %rax /* setcontext pushes the return */
addq $8, %rax /* address onto the stack; */
movq %rax, MC_RSP(%rdi) /* account for this -- ???. */
fnstcw MC_FP_CW_OFFSET(%rdi) /* save FPU control word */
movq $MC_OWNEDFP_NONE, MC_OWNEDFP_OFFSET(%rdi) /* no FP */
/*movq $MC_FPFMT_NODEV, MC_FPFMT_OFFSET(%rdi)*/ /* unused for amd64 */
movq $MC_SIZE, MC_LEN_OFFSET(%rdi)
xorq %rax, %rax /* return 0 */
2: ret
/*
* _amd64_ctx_restore(mcontext_t *mcp, intptr_t val, intptr_t *loc);
*/
ENTRY(_amd64_restore_context)
cmpq $0, %rdi /* check for null pointer */
jne 1f
movq $-1, %rax
jmp 7f
1: cmpq $MC_SIZE, MC_LEN_OFFSET(%rdi) /* is context valid? */
je 2f
movq $-1, %rax /* bzzzt, invalid context */
jmp 7f
2: movq MC_RCX(%rdi), %rcx
movq MC_R8(%rdi), %r8
movq MC_R9(%rdi), %r9
movq MC_RBX(%rdi), %rbx
movq MC_RBP(%rdi), %rbp
movq MC_R10(%rdi), %r10
movq MC_R11(%rdi), %r11
movq MC_R12(%rdi), %r12
movq MC_R13(%rdi), %r13
movq MC_R14(%rdi), %r14
movq MC_R15(%rdi), %r15
/*
* if (mc_fpowned == MC_OWNEDFP_FPU || mc_fpowned == MC_OWNEDFP_PCB)
* restore XMM/SSE FP register format
*/
cmpq $MC_OWNEDFP_NONE, MC_OWNEDFP_OFFSET(%rdi)
je 4f
cmpq $MC_OWNEDFP_PCB, MC_OWNEDFP_OFFSET(%rdi)
je 3f
cmpq $MC_OWNEDFP_FPU, MC_OWNEDFP_OFFSET(%rdi)
jne 4f
3: fxrstor MC_FPREGS_OFFSET(%rdi) /* restore XMM FP regs */
jmp 5f
4: fninit
fldcw MC_FP_CW_OFFSET(%rdi)
5: movq MC_RSP(%rdi), %rsp /* switch to context stack */
movq MC_RIP(%rdi), %rax /* return address on stack */
pushq %rax
movq MC_RDI(%rdi), %rax /* rdi on stack */
pushq %rax
movq MC_RDX(%rdi), %rax /* rdx on stack */
pushq %rax
movq MC_RSI(%rdi), %rax /* rsi on stack */
pushq %rax
movq MC_RFLAGS(%rdi), %rax /* flags on stack*/
pushq %rax
movq MC_RAX(%rdi), %rax /* restore rax */
/* At this point we're done with the context. */
cmpq $0, %rdx /* set *loc to val */
je 6f
movq %rsi, (%rdx)
6: popfq /* restore flags */
popq %rsi /* restore rsi, rdx, and rdi */
popq %rdx
popq %rdi
7: ret
-41
View File
@@ -1,41 +0,0 @@
/*
* Copyright (c) 2003 Daniel Eischen <deischen@freebsd.org>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/*
* _amd64_enter_uts(struct kse_mailbox *km, kse_func_t uts, void *stack,
* size_t stacksz);
*/
ENTRY(_amd64_enter_uts)
addq %rcx, %rdx /* get stack base */
andq $~0xf, %rdx /* align to 16 bytes */
subq $8, %rdx /* simulate "call" alignment */
movq %rdx, %rsp /* switch to UTS stack */
movq %rdx, %rbp /* set frame */
jmpq *%rsi
-73
View File
@@ -1,73 +0,0 @@
/*
* Copyright (c) 2003 Daniel Eischen <deischen@freebsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <stdlib.h>
#include <strings.h>
#include "pthread_md.h"
/*
* The constructors.
*/
struct tcb *
_tcb_ctor(struct pthread *thread)
{
struct tcb *tcb;
if ((tcb = malloc(sizeof(struct tcb))) != NULL) {
bzero(tcb, sizeof(struct tcb));
tcb->tcb_thread = thread;
/* Allocate TDV */
}
return (tcb);
}
void
_tcb_dtor(struct tcb *tcb)
{
/* Free TDV */
free(tcb);
}
struct kcb *
_kcb_ctor(struct kse *kse)
{
struct kcb *kcb;
if ((kcb = malloc(sizeof(struct kcb))) != NULL) {
bzero(kcb, sizeof(struct kcb));
kcb->kcb_kse = kse;
kcb->kcb_self = kcb;
}
return (kcb);
}
void
_kcb_dtor(struct kcb *kcb)
{
free(kcb);
}
@@ -1,57 +0,0 @@
/*-
* Copyright (c) 2001 Daniel Eischen <deischen@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _ATOMIC_OPS_H_
#define _ATOMIC_OPS_H_
/*
* Atomic swap:
* Atomic (tmp = *dst, *dst = val), then *res = tmp
*
* void atomic_swap64(intptr_t *dst, intptr_t val, intptr_t *res);
*/
static inline void
atomic_swap64(intptr_t *dst, intptr_t val, intptr_t *res)
{
__asm __volatile(
"xchgq %2, %1; movq %2, %0"
: "=m" (*res) : "m" (*dst), "r" (val) : "memory");
}
static inline void
atomic_swap_int(int *dst, int val, int *res)
{
__asm __volatile(
"xchgl %2, %1; movl %2, %0"
: "=m" (*res) : "m" (*dst), "r" (val) : "memory");
}
#define atomic_swap_ptr(d, v, r) \
atomic_swap64((intptr_t *)(d), (intptr_t)(v), (intptr_t *)(r))
#endif
-251
View File
@@ -1,251 +0,0 @@
/*-
* Copyright (C) 2003 David Xu <davidxu@freebsd.org>
* Copyright (c) 2001 Daniel Eischen <deischen@freebsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
/*
* Machine-dependent thread prototypes/definitions for the thread kernel.
*/
#ifndef _PTHREAD_MD_H_
#define _PTHREAD_MD_H_
#include <sys/types.h>
#include <sys/kse.h>
#include <machine/sysarch.h>
#include <ucontext.h>
#define KSE_STACKSIZE 16384
#define THR_GETCONTEXT(ucp) \
(void)_amd64_save_context(&(ucp)->uc_mcontext)
#define THR_SETCONTEXT(ucp) \
(void)_amd64_restore_context(&(ucp)->uc_mcontext, 0, NULL)
#define PER_KSE
#undef PER_THREAD
struct kse;
struct pthread;
struct tdv;
/*
* %fs points to a struct kcb.
*/
struct kcb {
struct tcb *kcb_curtcb;
struct kcb *kcb_self; /* self reference */
struct kse *kcb_kse;
struct kse_mailbox kcb_kmbx;
};
struct tcb {
struct tdv *tcb_tdv;
struct pthread *tcb_thread;
void *tcb_spare[2]; /* align tcb_tmbx to 16 bytes */
struct kse_thr_mailbox tcb_tmbx;
};
/*
* Evaluates to the byte offset of the per-kse variable name.
*/
#define __kcb_offset(name) __offsetof(struct kcb, name)
/*
* Evaluates to the type of the per-kse variable name.
*/
#define __kcb_type(name) __typeof(((struct kcb *)0)->name)
/*
* Evaluates to the value of the per-kse variable name.
*/
#define KCB_GET64(name) ({ \
__kcb_type(name) __result; \
\
u_long __i; \
__asm __volatile("movq %%fs:%1, %0" \
: "=r" (__i) \
: "m" (*(u_long *)(__kcb_offset(name)))); \
__result = *(__kcb_type(name) *)&__i; \
\
__result; \
})
/*
* Sets the value of the per-kse variable name to value val.
*/
#define KCB_SET64(name, val) ({ \
__kcb_type(name) __val = (val); \
\
u_long __i; \
__i = *(u_long *)&__val; \
__asm __volatile("movq %1,%%fs:%0" \
: "=m" (*(u_long *)(__kcb_offset(name))) \
: "r" (__i)); \
})
static __inline u_long
__kcb_readandclear64(volatile u_long *addr)
{
u_long result;
__asm __volatile (
" xorq %0, %0;"
" xchgq %%fs:%1, %0;"
"# __kcb_readandclear64"
: "=&r" (result)
: "m" (*addr));
return (result);
}
#define KCB_READANDCLEAR64(name) ({ \
__kcb_type(name) __result; \
\
__result = (__kcb_type(name)) \
__kcb_readandclear64((u_long *)__kcb_offset(name)); \
__result; \
})
#define _kcb_curkcb() KCB_GET64(kcb_self)
#define _kcb_curtcb() KCB_GET64(kcb_curtcb)
#define _kcb_curkse() ((struct kse *)KCB_GET64(kcb_kmbx.km_udata))
#define _kcb_get_tmbx() KCB_GET64(kcb_kmbx.km_curthread)
#define _kcb_set_tmbx(value) KCB_SET64(kcb_kmbx.km_curthread, (void *)value)
#define _kcb_readandclear_tmbx() KCB_READANDCLEAR64(kcb_kmbx.km_curthread)
/*
* The constructors.
*/
struct tcb *_tcb_ctor(struct pthread *);
void _tcb_dtor(struct tcb *tcb);
struct kcb *_kcb_ctor(struct kse *);
void _kcb_dtor(struct kcb *);
/* Called from the KSE to set its private data. */
static __inline void
_kcb_set(struct kcb *kcb)
{
amd64_set_fsbase(kcb);
}
/* Get the current kcb. */
static __inline struct kcb *
_kcb_get(void)
{
return (_kcb_curkcb());
}
static __inline struct kse_thr_mailbox *
_kcb_critical_enter(void)
{
struct kse_thr_mailbox *crit;
crit = _kcb_readandclear_tmbx();
return (crit);
}
static __inline void
_kcb_critical_leave(struct kse_thr_mailbox *crit)
{
_kcb_set_tmbx(crit);
}
static __inline int
_kcb_in_critical(void)
{
return (_kcb_get_tmbx() == NULL);
}
static __inline void
_tcb_set(struct kcb *kcb, struct tcb *tcb)
{
kcb->kcb_curtcb = tcb;
}
static __inline struct tcb *
_tcb_get(void)
{
return (_kcb_curtcb());
}
static __inline struct pthread *
_get_curthread(void)
{
struct tcb *tcb;
tcb = _kcb_curtcb();
if (tcb != NULL)
return (tcb->tcb_thread);
else
return (NULL);
}
static __inline struct kse *
_get_curkse(void)
{
return ((struct kse *)_kcb_curkse());
}
void _amd64_enter_uts(struct kse_mailbox *km, kse_func_t uts, void *stack,
size_t stacksz);
int _amd64_restore_context(mcontext_t *mc, intptr_t val, intptr_t *loc);
int _amd64_save_context(mcontext_t *mc);
static __inline int
_thread_enter_uts(struct tcb *tcb, struct kcb *kcb)
{
int ret;
ret = _amd64_save_context(&tcb->tcb_tmbx.tm_context.uc_mcontext);
if (ret == 0) {
_amd64_enter_uts(&kcb->kcb_kmbx, kcb->kcb_kmbx.km_func,
kcb->kcb_kmbx.km_stack.ss_sp,
kcb->kcb_kmbx.km_stack.ss_size);
/* We should not reach here. */
return (-1);
}
else if (ret < 0)
return (-1);
return (0);
}
static __inline int
_thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox)
{
if ((kcb == NULL) || (tcb == NULL))
return (-1);
kcb->kcb_curtcb = tcb;
if (setmbox != 0)
_amd64_restore_context(&tcb->tcb_tmbx.tm_context.uc_mcontext,
(intptr_t)&tcb->tcb_tmbx,
(intptr_t *)&kcb->kcb_kmbx.km_curthread);
else
_amd64_restore_context(&tcb->tcb_tmbx.tm_context.uc_mcontext,
0, NULL);
/* We should not reach here. */
return (-1);
}
#endif
-5
View File
@@ -1,5 +0,0 @@
# $FreeBSD$
.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/${MACHINE_ARCH}
SRCS+= thr_enter_uts.S thr_getcontext.S pthread_md.c
-114
View File
@@ -1,114 +0,0 @@
/*-
* Copyright (C) 2003 David Xu <davidxu@freebsd.org>
* Copyright (c) 2001,2003 Daniel Eischen <deischen@freebsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <machine/cpufunc.h>
#include <machine/segments.h>
#include <machine/sysarch.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <ucontext.h>
#include "pthread_md.h"
struct tcb *
_tcb_ctor(struct pthread *thread)
{
struct tcb *tcb;
void *addr;
addr = malloc(sizeof(struct tcb) + 15);
if (addr == NULL)
tcb = NULL;
else {
tcb = (struct tcb *)(((uintptr_t)(addr) + 15) & ~15);
bzero(tcb, sizeof(struct tcb));
tcb->tcb_addr = addr;
tcb->tcb_thread = thread;
/* XXX - Allocate tdv/tls */
}
return (tcb);
}
void
_tcb_dtor(struct tcb *tcb)
{
void *addr;
addr = tcb->tcb_addr;
tcb->tcb_addr = NULL;
free(addr);
}
/*
* Initialize KSD. This also includes setting up the LDT.
*/
struct kcb *
_kcb_ctor(struct kse *kse)
{
union descriptor ldt;
struct kcb *kcb;
kcb = malloc(sizeof(struct kcb));
if (kcb != NULL) {
bzero(kcb, sizeof(struct kcb));
kcb->kcb_self = kcb;
kcb->kcb_kse = kse;
ldt.sd.sd_hibase = (unsigned int)kcb >> 24;
ldt.sd.sd_lobase = (unsigned int)kcb & 0xFFFFFF;
ldt.sd.sd_hilimit = (sizeof(struct kcb) >> 16) & 0xF;
ldt.sd.sd_lolimit = sizeof(struct kcb) & 0xFFFF;
ldt.sd.sd_type = SDT_MEMRWA;
ldt.sd.sd_dpl = SEL_UPL;
ldt.sd.sd_p = 1;
ldt.sd.sd_xx = 0;
ldt.sd.sd_def32 = 1;
ldt.sd.sd_gran = 0; /* no more than 1M */
kcb->kcb_ldt = i386_set_ldt(LDT_AUTO_ALLOC, &ldt, 1);
if (kcb->kcb_ldt < 0) {
free(kcb);
return (NULL);
}
}
return (kcb);
}
void
_kcb_dtor(struct kcb *kcb)
{
if (kcb->kcb_ldt >= 0) {
i386_set_ldt(kcb->kcb_ldt, NULL, 1);
kcb->kcb_ldt = -1; /* just in case */
}
free(kcb);
}
-44
View File
@@ -1,44 +0,0 @@
/*
* Copyright (c) 2002 Jonathan Mini <mini@freebsd.org>.
* Copyright (c) 2001 Daniel Eischen <deischen@freebsd.org>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/*
* _i386_enter_uts(struct kse_mailbox *km, kse_func_t uts, void *stack,
* long stacksz);
* +4 = km, +8 = uts, +12 = stack, +16 = size
*/
ENTRY(_i386_enter_uts)
movl %esp, %edx /* save stack */
movl 12(%edx), %eax /* get bottom of stack */
addl 16(%edx), %eax /* add length */
movl %eax, %esp /* switch to uts stack */
pushl 4(%edx) /* push the address of the mailbox */
call *8(%edx)
ret
-156
View File
@@ -1,156 +0,0 @@
/*-
* Copyright (c) 2001 Daniel Eischen <deischen@freebsd.org>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/*
* Where do we define these?
*/
#define MC_LEN_OFFSET 80 /* offset to mc_len from mcontext */
#define MC_LEN 640 /* mc_len <machine/ucontext.h> */
#define MC_FPFMT_OFFSET 84
#define MC_FPFMT_NODEV 0x10000
#define MC_FPFMT_387 0x10001
#define MC_FPFMT_XMM 0x10002
#define MC_OWNEDFP_OFFSET 88
#define MC_OWNEDFP_NONE 0x20000
#define MC_OWNEDFP_FPU 0x20001
#define MC_OWNEDFP_PCB 0x20002
#define MC_FPREGS_OFFSET 96 /* offset to FP regs from mcontext */
#define MC_FP_CW_OFFSET 96 /* offset to FP control word */
/*
* int thr_setcontext(mcontext_t *mcp, intptr_t val, intptr_t *loc)
*
* Restores the context in mcp.
*
* Returns 0 if there are no errors; -1 otherwise
*/
.weak CNAME(_thr_setcontext)
.set CNAME(_thr_setcontext),CNAME(__thr_setcontext)
ENTRY(__thr_setcontext)
movl 4(%esp), %edx /* get address of mcontext */
cmpl $0, %edx /* check for null pointer */
jne 1f
movl $-1, %eax
jmp 8f
1: cmpl $MC_LEN, MC_LEN_OFFSET(%edx) /* is context valid? */
je 2f
movl $-1, %eax /* bzzzt, invalid context */
jmp 8f
2: /*movl 4(%edx), %gs*/ /* we don't touch %gs */
movl 8(%edx), %fs
movl 12(%edx), %es
movl 16(%edx), %ds
movl 76(%edx), %ss
movl 20(%edx), %edi
movl 24(%edx), %esi
movl 28(%edx), %ebp
movl %esp, %ecx /* save current stack in ecx */
movl 72(%edx), %esp /* switch to context defined stack */
pushl 60(%edx) /* push return address on stack */
pushl 44(%edx) /* push ecx on stack */
pushl 48(%edx) /* push eax on stack */
/*
* if (mc_fpowned == MC_OWNEDFP_FPU || mc_fpowned == MC_OWNEDFP_PCB) {
* if (mc_fpformat == MC_FPFMT_387)
* restore 387 FP register format
* else if (mc_fpformat == MC_FPFMT_XMM)
* restore XMM/SSE FP register format
* }
*/
cmpl $MC_OWNEDFP_FPU, MC_OWNEDFP_OFFSET(%edx)
je 3f
cmpl $MC_OWNEDFP_PCB, MC_OWNEDFP_OFFSET(%edx)
jne 5f
3: cmpl $MC_FPFMT_387, MC_FPFMT_OFFSET(%edx)
jne 4f
frstor MC_FPREGS_OFFSET(%edx) /* restore 387 FP regs */
jmp 6f
4: cmpl $MC_FPFMT_XMM, MC_FPFMT_OFFSET(%edx)
jne 5f
fxrstor MC_FPREGS_OFFSET(%edx) /* restore XMM FP regs */
jmp 6f
5: fninit
fldcw MC_FP_CW_OFFSET(%edx)
6: pushl 68(%edx) /* push flags register on stack*/
movl 36(%edx), %ebx /* restore ebx and edx */
movl 40(%edx), %edx
movl 12(%ecx), %eax /* get 3rd arg (loc) */
cmpl $0, %eax /* do nothing if loc == null */
je 7f
movl 8(%ecx), %ecx /* get 2nd arg (val) */
movl %ecx, (%eax) /* set loc = val */
7: popfl /* restore flags after test */
popl %eax /* restore eax and ecx last */
popl %ecx
8: ret
/*
* int thr_getcontext(mcontext_t *mcp);
*
* Returns -1 if there is an error, 0 no errors; 1 upon return
* from a setcontext().
*/
.weak CNAME(_thr_getcontext)
.set CNAME(_thr_getcontext),CNAME(__thr_getcontext)
ENTRY(__thr_getcontext)
pushl %edx /* save edx */
movl 8(%esp), %edx /* get address of mcontext */
cmpl $0, %edx /* check for null pointer */
jne 1f
popl %edx /* restore edx and stack */
movl $-1, %eax
jmp 2f
1: /*movl %gs, 4(%edx)*/ /* we don't touch %gs */
movl %fs, 8(%edx)
movl %es, 12(%edx)
movl %ds, 16(%edx)
movl %ss, 76(%edx)
movl %edi, 20(%edx)
movl %esi, 24(%edx)
movl %ebp, 28(%edx)
movl %ebx, 36(%edx)
movl $1, 48(%edx) /* store successful return in eax */
popl %eax /* get saved value of edx */
movl %eax, 40(%edx) /* save edx */
movl %ecx, 44(%edx)
movl (%esp), %eax /* get return address */
movl %eax, 60(%edx) /* save return address */
fnstcw MC_FP_CW_OFFSET(%edx)
movl $MC_LEN, MC_LEN_OFFSET(%edx)
movl $MC_FPFMT_NODEV, MC_FPFMT_OFFSET(%edx) /* no FP */
movl $MC_OWNEDFP_NONE, MC_OWNEDFP_OFFSET(%edx) /* no FP */
pushfl
popl %eax /* get eflags */
movl %eax, 68(%edx) /* store eflags */
movl %esp, %eax /* setcontext pushes the return */
addl $4, %eax /* address onto the top of the */
movl %eax, 72(%edx) /* stack; account for this */
movl 40(%edx), %edx /* restore edx -- is this needed? */
xorl %eax, %eax /* return 0 */
2: ret
-51
View File
@@ -1,51 +0,0 @@
/*-
* Copyright (c) 2001 Daniel Eischen <deischen@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _ATOMIC_OPS_H_
#define _ATOMIC_OPS_H_
/*
* Atomic swap:
* Atomic (tmp = *dst, *dst = val), then *res = tmp
*
* void atomic_swap32(intptr_t *dst, intptr_t val, intptr_t *res);
*/
static inline void
atomic_swap32(intptr_t *dst, intptr_t val, intptr_t *res)
{
__asm __volatile(
"xchgl %2, %1; movl %2, %0"
: "=m" (*res) : "m" (*dst), "r" (val) : "memory");
}
#define atomic_swap_ptr(d, v, r) \
atomic_swap32((intptr_t *)d, (intptr_t)v, (intptr_t *)r)
#define atomic_swap_int(d, v, r) \
atomic_swap32((intptr_t *)d, (intptr_t)v, (intptr_t *)r)
#endif
-253
View File
@@ -1,253 +0,0 @@
/*-
* Copyright (c) 2002 Daniel Eischen <deischen@freebsd.org>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
/*
* Machine-dependent thread prototypes/definitions for the thread kernel.
*/
#ifndef _PTHREAD_MD_H_
#define _PTHREAD_MD_H_
#include <sys/kse.h>
#include <ucontext.h>
extern int _thr_setcontext(mcontext_t *, intptr_t, intptr_t *);
extern int _thr_getcontext(mcontext_t *);
#define KSE_STACKSIZE 16384
#define THR_GETCONTEXT(ucp) _thr_getcontext(&(ucp)->uc_mcontext)
#define THR_SETCONTEXT(ucp) _thr_setcontext(&(ucp)->uc_mcontext, 0, NULL)
#define PER_KSE
#undef PER_THREAD
struct kse;
struct pthread;
struct tdv;
/*
* %gs points to a struct kcb.
*/
struct kcb {
struct tcb *kcb_curtcb;
struct kcb *kcb_self; /* self reference */
int kcb_ldt;
struct kse *kcb_kse;
struct kse_mailbox kcb_kmbx;
};
struct tcb {
struct tdv *tcb_tdv;
struct pthread *tcb_thread;
void *tcb_addr; /* allocated tcb address */
void *tcb_spare; /* align tcb_tmbx to 16 bytes */
struct kse_thr_mailbox tcb_tmbx;
};
/*
* Evaluates to the byte offset of the per-kse variable name.
*/
#define __kcb_offset(name) __offsetof(struct kcb, name)
/*
* Evaluates to the type of the per-kse variable name.
*/
#define __kcb_type(name) __typeof(((struct kcb *)0)->name)
/*
* Evaluates to the value of the per-kse variable name.
*/
#define KCB_GET32(name) ({ \
__kcb_type(name) __result; \
\
u_int __i; \
__asm __volatile("movl %%gs:%1, %0" \
: "=r" (__i) \
: "m" (*(u_int *)(__kcb_offset(name)))); \
__result = *(__kcb_type(name) *)&__i; \
\
__result; \
})
/*
* Sets the value of the per-kse variable name to value val.
*/
#define KCB_SET32(name, val) ({ \
__kcb_type(name) __val = (val); \
\
u_int __i; \
__i = *(u_int *)&__val; \
__asm __volatile("movl %1,%%gs:%0" \
: "=m" (*(u_int *)(__kcb_offset(name))) \
: "r" (__i)); \
})
static __inline u_long
__kcb_readandclear32(volatile u_long *addr)
{
u_long result;
__asm __volatile (
" xorl %0, %0;"
" xchgl %%gs:%1, %0;"
"# __kcb_readandclear32"
: "=&r" (result)
: "m" (*addr));
return (result);
}
#define KCB_READANDCLEAR32(name) ({ \
__kcb_type(name) __result; \
\
__result = (__kcb_type(name)) \
__kcb_readandclear32((u_long *)__kcb_offset(name)); \
__result; \
})
#define _kcb_curkcb() KCB_GET32(kcb_self)
#define _kcb_curtcb() KCB_GET32(kcb_curtcb)
#define _kcb_curkse() ((struct kse *)KCB_GET32(kcb_kmbx.km_udata))
#define _kcb_get_tmbx() KCB_GET32(kcb_kmbx.km_curthread)
#define _kcb_set_tmbx(value) KCB_SET32(kcb_kmbx.km_curthread, (void *)value)
#define _kcb_readandclear_tmbx() KCB_READANDCLEAR32(kcb_kmbx.km_curthread)
/*
* The constructors.
*/
struct tcb *_tcb_ctor(struct pthread *);
void _tcb_dtor(struct tcb *tcb);
struct kcb *_kcb_ctor(struct kse *);
void _kcb_dtor(struct kcb *);
/* Called from the KSE to set its private data. */
static __inline void
_kcb_set(struct kcb *kcb)
{
int val;
val = (kcb->kcb_ldt << 3) | 7;
__asm __volatile("movl %0, %%gs" : : "r" (val));
}
/* Get the current kcb. */
static __inline struct kcb *
_kcb_get(void)
{
return (_kcb_curkcb());
}
static __inline struct kse_thr_mailbox *
_kcb_critical_enter(void)
{
struct kse_thr_mailbox *crit;
crit = _kcb_readandclear_tmbx();
return (crit);
}
static __inline void
_kcb_critical_leave(struct kse_thr_mailbox *crit)
{
_kcb_set_tmbx(crit);
}
static __inline int
_kcb_in_critical(void)
{
return (_kcb_get_tmbx() == NULL);
}
static __inline void
_tcb_set(struct kcb *kcb, struct tcb *tcb)
{
kcb->kcb_curtcb = tcb;
}
static __inline struct tcb *
_tcb_get(void)
{
return (_kcb_curtcb());
}
static __inline struct pthread *
_get_curthread(void)
{
struct tcb *tcb;
tcb = _kcb_curtcb();
if (tcb != NULL)
return (tcb->tcb_thread);
else
return (NULL);
}
static __inline struct kse *
_get_curkse(void)
{
return ((struct kse *)_kcb_curkse());
}
void _i386_enter_uts(struct kse_mailbox *km, kse_func_t uts, void *stack,
size_t stacksz);
static __inline int
_thread_enter_uts(struct tcb *tcb, struct kcb *kcb)
{
int ret;
ret = _thr_getcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext);
if (ret == 0) {
_i386_enter_uts(&kcb->kcb_kmbx, kcb->kcb_kmbx.km_func,
kcb->kcb_kmbx.km_stack.ss_sp,
kcb->kcb_kmbx.km_stack.ss_size);
/* We should not reach here. */
return (-1);
}
else if (ret < 0)
return (-1);
return (0);
}
static __inline int
_thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox)
{
if ((kcb == NULL) || (tcb == NULL))
return (-1);
kcb->kcb_curtcb = tcb;
if (setmbox != 0)
_thr_setcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext,
(intptr_t)&tcb->tcb_tmbx,
(intptr_t *)&kcb->kcb_kmbx.km_curthread);
else
_thr_setcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext, 0, NULL);
/* We should not reach here. */
return (-1);
}
#endif
-5
View File
@@ -1,5 +0,0 @@
# $FreeBSD$
.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/${MACHINE_ARCH}
SRCS+= context.S enter_uts.S pthread_md.c
-351
View File
@@ -1,351 +0,0 @@
/*
* Copyright (c) 2003 Marcel Moolenaar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
#include <sys/syscall.h>
#define SIZEOF_SPECIAL (18*8)
/*
* int _ia64_restore_context(mcontext_t *mc, intptr_t val, intptr_t *loc);
*/
ENTRY(_ia64_restore_context, 3)
{ .mmi
invala
mov ar.rsc=0xc
add r32=16,r32
;;
}
{ .mmi
loadrs
ld8 r12=[r32] // sp
add r31=8,r32
;;
}
{ .mii
ld8 r16=[r31],16 // unat (before)
add r30=16,r32
add r14=SIZEOF_SPECIAL,r32
;;
}
{ .mmi
ld8 r17=[r30],16 // rp
ld8 r18=[r31],16 // pr
mov r2=r33
;;
}
{ .mmi
ld8 r19=[r30],16 // pfs
ld8 r20=[r31],32 // bspstore
mov rp=r17
;;
}
{ .mmi
ld8 r21=[r30],32 // rnat
ld8 r22=[r31],16 // rsc
mov pr=r18,0x1fffe
;;
}
{ .mmi
ld8 r23=[r30] // fpsr
ld8 r24=[r31] // psr -- not used
mov r3=r34
;;
}
{ .mmi
ld8 r17=[r14],8 // unat (after)
mov ar.bspstore=r20
cmp.ne p15,p0=r0,r3
;;
}
{ .mmi
mov ar.rnat=r21
mov ar.unat=r17
add r15=8,r14
;;
}
{ .mmi
ld8.fill r4=[r14],16 // r4
ld8.fill r5=[r15],16 // r5
mov ar.pfs=r19
;;
}
{ .mmi
ld8.fill r6=[r14],16 // r6
ld8.fill r7=[r15],16 // r7
nop 0
;;
}
{ .mmi
mov ar.unat=r16
mov ar.rsc=r22
nop 0
}
{ .mmi
ld8 r17=[r14],16 // b1
ld8 r18=[r15],16 // b2
nop 0
;;
}
{ .mmi
ld8 r19=[r14],16 // b3
ld8 r20=[r15],16 // b4
mov b1=r17
;;
}
{ .mmi
ld8 r16=[r14],24 // b5
ld8 r17=[r15],32 // lc
mov b2=r18
;;
}
{ .mmi
ldf.fill f2=[r14],32
ldf.fill f3=[r15],32
mov b3=r19
;;
}
{ .mmi
ldf.fill f4=[r14],32
ldf.fill f5=[r15],32
mov b4=r20
;;
}
{ .mmi
ldf.fill f16=[r14],32
ldf.fill f17=[r15],32
mov b5=r16
;;
}
{ .mmi
ldf.fill f18=[r14],32
ldf.fill f19=[r15],32
mov ar.lc=r17
;;
}
ldf.fill f20=[r14],32
ldf.fill f21=[r15],32
;;
ldf.fill f22=[r14],32
ldf.fill f23=[r15],32
;;
ldf.fill f24=[r14],32
ldf.fill f25=[r15],32
;;
ldf.fill f26=[r14],32
ldf.fill f27=[r15],32
;;
ldf.fill f28=[r14],32
ldf.fill f29=[r15],32
;;
ldf.fill f30=[r14],32+24
ldf.fill f31=[r15],24+24
;;
ld8 r8=[r14],16
ld8 r9=[r15],16
;;
ld8 r10=[r14]
ld8 r11=[r15]
;;
{ .mmb
(p15) st8 [r3]=r2
mov ar.fpsr=r23
br.ret.sptk rp
;;
}
END(_ia64_restore_context)
/*
* int _ia64_save_context(mcontext_t *mc);
*/
ENTRY(_ia64_save_context, 1)
{ .mmi
mov r14=ar.rsc
mov r15=ar.fpsr
add r31=8,r32
;;
}
{ .mmi
st8 [r32]=r0,16
st8 [r31]=r0,16
nop 0
;;
}
{ .mmi
mov ar.rsc=0xc
mov r16=ar.unat
nop 0
;;
}
{ .mmi
flushrs
st8 [r32]=sp,16 // sp
mov r17=rp
;;
}
{ .mmi
st8 [r31]=r16,16 // unat (before)
st8 [r32]=r17,16 // rp
mov r16=pr
;;
}
{ .mmi
st8 [r31]=r16,16 // pr
mov r17=ar.bsp
mov r16=ar.pfs
;;
}
{ .mmi
st8 [r32]=r16,16 // pfs
st8 [r31]=r17,16 // bspstore
nop 0
;;
}
{ .mmi
mov r16=ar.rnat
mov ar.rsc=r14
add r30=SIZEOF_SPECIAL-(6*8),r32
;;
}
{ .mmi
st8 [r32]=r16,16 // rnat
st8 [r31]=r0,16 // __spare
nop 0
;;
}
{ .mmi
st8 [r32]=r13,16 // tp -- not used
st8 [r31]=r14,16 // rsc
mov r16=b1
;;
}
{ .mmi
st8 [r32]=r15,10*8 // fpr
st8 [r31]=r0,8*8 // psr
nop 0
;;
}
/* callee_saved */
{ .mmi
.mem.offset 8,0
st8.spill [r31]=r4,16 // r4
.mem.offset 16,0
st8.spill [r32]=r5,16 // r5
mov r17=b2
;;
}
{ .mmi
.mem.offset 24,0
st8.spill [r31]=r6,16 // r6
.mem.offset 32,0
st8.spill [r32]=r7,16 // r7
mov r18=b3
;;
}
{ .mmi
st8 [r31]=r16,16 // b1
mov r16=ar.unat
mov r19=b4
;;
}
{ .mmi
st8 [r30]=r16 // unat (after)
st8 [r32]=r17,16 // b2
mov r16=b5
;;
}
{ .mmi
st8 [r31]=r18,16 // b3
st8 [r32]=r19,16 // b4
mov r17=ar.lc
;;
}
st8 [r31]=r16,16 // b5
st8 [r32]=r17,16 // lc
;;
st8 [r31]=r0,24 // __spare
stf.spill [r32]=f2,32
;;
stf.spill [r31]=f3,32
stf.spill [r32]=f4,32
;;
stf.spill [r31]=f5,32
stf.spill [r32]=f16,32
;;
stf.spill [r31]=f17,32
stf.spill [r32]=f18,32
;;
stf.spill [r31]=f19,32
stf.spill [r32]=f20,32
;;
stf.spill [r31]=f21,32
stf.spill [r32]=f22,32
;;
stf.spill [r31]=f23,32
stf.spill [r32]=f24,32
;;
stf.spill [r31]=f25,32
stf.spill [r32]=f26,32
;;
stf.spill [r31]=f27,32
stf.spill [r32]=f28,32
;;
{ .mmi
stf.spill [r31]=f29,32
stf.spill [r32]=f30,32+24
add r14=1,r0
;;
}
{ .mmi
stf.spill [r31]=f31,24+24
st8 [r32]=r14,16 // r8
add r8=0,r0
;;
}
st8 [r31]=r0,16 // r9
st8 [r32]=r0 // r10
;;
{ .mmb
st8 [r31]=r0 // r11
mf
br.ret.sptk rp
;;
}
END(_ia64_save_context)
/*
* void _ia64_break_setcontext(mcontext_t *mc);
*/
ENTRY(_ia64_break_setcontext, 1)
{ .mmi
mov r8=r32
break 0x180000
nop 0
;;
}
END(_ia64_break_setcontext)
-60
View File
@@ -1,60 +0,0 @@
/*
* Copyright (c) 2003 Marcel Moolenaar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/*
* void _ia64_enter_uts(kse_func_t uts, struct kse_mailbox *km, void *stack,
* size_t stacksz);
*/
ENTRY(_ia64_enter_uts, 4)
{ .mmi
ld8 r14=[in0],8
mov ar.rsc=0xc
add r15=in2,in3
;;
}
{ .mmi
flushrs
ld8 r1=[in0]
mov b7=r14
;;
}
{ .mii
mov ar.bspstore=in2
add sp=-16,r15
mov rp=r14
;;
}
{ .mib
mov ar.rsc=0xf
mov in0=in1
br.cond.sptk b7
;;
}
1: br.cond.sptk 1b
END(_ia64_enter_uts)
-75
View File
@@ -1,75 +0,0 @@
/*
* Copyright (c) 2003 Daniel Eischen <deischen@freebsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <stdlib.h>
#include <strings.h>
#include "pthread_md.h"
/*
* The constructors.
*/
struct tcb *
_tcb_ctor(struct pthread *thread)
{
struct tcb *tcb;
if ((tcb = malloc(sizeof(struct tcb))) != NULL) {
bzero(tcb, sizeof(struct tcb));
tcb->tcb_thread = thread;
/* Allocate TDV */
}
return (tcb);
}
void
_tcb_dtor(struct tcb *tcb)
{
/* Free TDV */
free(tcb);
}
struct kcb *
_kcb_ctor(struct kse *kse)
{
struct kcb *kcb;
if ((kcb = malloc(sizeof(struct kcb))) != NULL) {
bzero(kcb, sizeof(struct kcb));
kcb->kcb_faketcb.tcb_isfake = 1;
kcb->kcb_faketcb.tcb_tmbx.tm_flags = TMF_NOUPCALL;
kcb->kcb_curtcb = &kcb->kcb_faketcb;
kcb->kcb_kse = kse;
}
return (kcb);
}
void
_kcb_dtor(struct kcb *kcb)
{
free(kcb);
}
-246
View File
@@ -1,246 +0,0 @@
/*
* Copyright (c) 2003 Marcel Moolenaar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _PTHREAD_MD_H_
#define _PTHREAD_MD_H_
#include <sys/kse.h>
#include <stddef.h>
#include <ucontext.h>
#define KSE_STACKSIZE 16384
#define THR_GETCONTEXT(ucp) _ia64_save_context(&(ucp)->uc_mcontext)
#define THR_SETCONTEXT(ucp) PANIC("THR_SETCONTEXT() now in use!\n")
#define PER_THREAD
struct kcb;
struct kse;
struct pthread;
struct tcb;
struct tdv; /* We don't know what this is yet? */
/*
* tp points to one of these. We define the static TLS as an array
* of long double to enforce 16-byte alignment of the TLS memory,
* struct ia64_tp, struct tcb and also struct kcb. Both static and
* dynamic allocation of any of these structures will result in a
* valid, well-aligned thread pointer.
*/
struct ia64_tp {
struct tdv *tp_tdv; /* dynamic TLS */
uint64_t _reserved_;
long double tp_tls[0]; /* static TLS */
};
struct tcb {
struct kse_thr_mailbox tcb_tmbx;
struct pthread *tcb_thread;
struct kcb *tcb_curkcb;
long tcb_isfake;
struct ia64_tp tcb_tp;
};
struct kcb {
struct kse_mailbox kcb_kmbx;
struct tcb kcb_faketcb;
struct tcb *kcb_curtcb;
struct kse *kcb_kse;
};
register struct ia64_tp *_tp __asm("%r13");
#define _tcb ((struct tcb*)((char*)(_tp) - offsetof(struct tcb, tcb_tp)))
/*
* The kcb and tcb constructors.
*/
struct tcb *_tcb_ctor(struct pthread *);
void _tcb_dtor(struct tcb *);
struct kcb *_kcb_ctor(struct kse *kse);
void _kcb_dtor(struct kcb *);
/* Called from the KSE to set its private data. */
static __inline void
_kcb_set(struct kcb *kcb)
{
/* There is no thread yet; use the fake tcb. */
_tp = &kcb->kcb_faketcb.tcb_tp;
}
/*
* Get the current kcb.
*
* This can only be called while in a critical region; don't
* worry about having the kcb changed out from under us.
*/
static __inline struct kcb *
_kcb_get(void)
{
return (_tcb->tcb_curkcb);
}
/*
* Enter a critical region.
*
* Read and clear km_curthread in the kse mailbox.
*/
static __inline struct kse_thr_mailbox *
_kcb_critical_enter(void)
{
struct kse_thr_mailbox *crit;
uint32_t flags;
if (_tcb->tcb_isfake != 0) {
/*
* We already are in a critical region since
* there is no current thread.
*/
crit = NULL;
} else {
flags = _tcb->tcb_tmbx.tm_flags;
_tcb->tcb_tmbx.tm_flags |= TMF_NOUPCALL;
crit = _tcb->tcb_curkcb->kcb_kmbx.km_curthread;
_tcb->tcb_curkcb->kcb_kmbx.km_curthread = NULL;
_tcb->tcb_tmbx.tm_flags = flags;
}
return (crit);
}
static __inline void
_kcb_critical_leave(struct kse_thr_mailbox *crit)
{
/* No need to do anything if this is a fake tcb. */
if (_tcb->tcb_isfake == 0)
_tcb->tcb_curkcb->kcb_kmbx.km_curthread = crit;
}
static __inline int
_kcb_in_critical(void)
{
uint32_t flags;
int ret;
if (_tcb->tcb_isfake != 0) {
/*
* We are in a critical region since there is no
* current thread.
*/
ret = 1;
} else {
flags = _tcb->tcb_tmbx.tm_flags;
_tcb->tcb_tmbx.tm_flags |= TMF_NOUPCALL;
ret = (_tcb->tcb_curkcb->kcb_kmbx.km_curthread == NULL);
_tcb->tcb_tmbx.tm_flags = flags;
}
return (ret);
}
static __inline void
_tcb_set(struct kcb *kcb, struct tcb *tcb)
{
if (tcb == NULL)
tcb = &kcb->kcb_faketcb;
kcb->kcb_curtcb = tcb;
tcb->tcb_curkcb = kcb;
_tp = &tcb->tcb_tp;
}
static __inline struct tcb *
_tcb_get(void)
{
return (_tcb);
}
static __inline struct pthread *
_get_curthread(void)
{
return (_tcb->tcb_thread);
}
/*
* Get the current kse.
*
* Like _kcb_get(), this can only be called while in a critical region.
*/
static __inline struct kse *
_get_curkse(void)
{
return (_tcb->tcb_curkcb->kcb_kse);
}
void _ia64_break_setcontext(mcontext_t *mc);
void _ia64_enter_uts(kse_func_t uts, struct kse_mailbox *km, void *stack,
size_t stacksz);
int _ia64_restore_context(mcontext_t *mc, intptr_t val, intptr_t *loc);
int _ia64_save_context(mcontext_t *mc);
static __inline int
_thread_enter_uts(struct tcb *tcb, struct kcb *kcb)
{
if (_ia64_save_context(&tcb->tcb_tmbx.tm_context.uc_mcontext) == 0) {
/* Make the fake tcb the current thread. */
kcb->kcb_curtcb = &kcb->kcb_faketcb;
_tp = &kcb->kcb_faketcb.tcb_tp;
_ia64_enter_uts(kcb->kcb_kmbx.km_func, &kcb->kcb_kmbx,
kcb->kcb_kmbx.km_stack.ss_sp,
kcb->kcb_kmbx.km_stack.ss_size);
/* We should not reach here. */
return (-1);
}
return (0);
}
static __inline int
_thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox)
{
mcontext_t *mc;
_tcb_set(kcb, tcb);
mc = &tcb->tcb_tmbx.tm_context.uc_mcontext;
if (mc->mc_flags & _MC_FLAGS_ASYNC_CONTEXT) {
if (setmbox) {
mc->mc_flags |= _MC_FLAGS_KSE_SET_MBOX;
mc->mc_special.ifa =
(intptr_t)&kcb->kcb_kmbx.km_curthread;
mc->mc_special.isr = (intptr_t)&tcb->tcb_tmbx;
}
_ia64_break_setcontext(mc);
} else {
if (setmbox)
_ia64_restore_context(mc, (intptr_t)&tcb->tcb_tmbx,
(intptr_t *)&kcb->kcb_kmbx.km_curthread);
else
_ia64_restore_context(mc, 0, NULL);
}
/* We should not reach here. */
return (-1);
}
#endif /* _PTHREAD_MD_H_ */
-5
View File
@@ -1,5 +0,0 @@
# $FreeBSD$
.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/${MACHINE_ARCH}
SRCS+= pthread_md.c thr_getcontext.S
@@ -1,75 +0,0 @@
/*-
* Copyright (c) 2003 Jake Burkholder <jake@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _ATOMIC_OPS_H_
#define _ATOMIC_OPS_H_
#include <machine/atomic.h>
/*
* Atomic swap:
* Atomic (tmp = *dst, *dst = val), then *res = tmp
*
* void atomic_swap_long(long *dst, long val, long *res);
*/
static __inline void
atomic_swap_long(long *dst, long val, long *res)
{
long tmp;
long r;
tmp = *dst;
for (;;) {
r = atomic_cas_64(dst, tmp, val);
if (r == tmp)
break;
tmp = r;
}
*res = tmp;
}
static __inline void
atomic_swap_int(int *dst, int val, int *res)
{
int tmp;
int r;
tmp = *dst;
for (;;) {
r = atomic_cas_32(dst, tmp, val);
if (r == tmp)
break;
tmp = r;
}
*res = tmp;
}
#define atomic_swap_ptr(dst, val, res) \
atomic_swap_long((long *)dst, (long)val, (long *)res)
#endif
@@ -1,243 +0,0 @@
/*-
* Copyright (c) 2003 Jake Burkholder <jake@freebsd.org>.
* Copyright (c) 2003 Marcel Moolenaar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
/*
* Machine-dependent thread prototypes/definitions for the thread kernel.
*/
#ifndef _PTHREAD_MD_H_
#define _PTHREAD_MD_H_
#include <sys/kse.h>
#include <stddef.h>
#include <ucontext.h>
#define KSE_STACKSIZE 16384
int _thr_setcontext(mcontext_t *, intptr_t, intptr_t *);
int _thr_getcontext(mcontext_t *);
#define THR_GETCONTEXT(ucp) _thr_getcontext(&(ucp)->uc_mcontext)
#define THR_SETCONTEXT(ucp) _thr_setcontext(&(ucp)->uc_mcontext, 0, NULL)
#define PER_THREAD
struct kcb;
struct kse;
struct pthread;
struct tcb;
struct tdv; /* We don't know what this is yet? */
/*
* %g6 points to one of these. We define the static TLS as an array
* of long double to enforce 16-byte alignment of the TLS memory.
*
* XXX - Both static and dynamic allocation of any of these structures
* will result in a valid, well-aligned thread pointer???
*/
struct sparc64_tp {
struct tdv *tp_tdv; /* dynamic TLS */
uint64_t _reserved_;
long double tp_tls[0]; /* static TLS */
};
struct tcb {
struct pthread *tcb_thread;
void *tcb_addr; /* allocated tcb address */
struct kcb *tcb_curkcb;
uint64_t tcb_isfake;
uint64_t tcb_spare[4];
struct kse_thr_mailbox tcb_tmbx; /* needs 64-byte alignment */
struct sparc64_tp tcb_tp;
} __aligned(64);
struct kcb {
struct kse_mailbox kcb_kmbx;
struct tcb kcb_faketcb;
struct tcb *kcb_curtcb;
struct kse *kcb_kse;
};
register struct sparc64_tp *_tp __asm("%g6");
#define _tcb ((struct tcb*)((char*)(_tp) - offsetof(struct tcb, tcb_tp)))
/*
* The kcb and tcb constructors.
*/
struct tcb *_tcb_ctor(struct pthread *);
void _tcb_dtor(struct tcb *);
struct kcb *_kcb_ctor(struct kse *kse);
void _kcb_dtor(struct kcb *);
/* Called from the KSE to set its private data. */
static __inline void
_kcb_set(struct kcb *kcb)
{
/* There is no thread yet; use the fake tcb. */
_tp = &kcb->kcb_faketcb.tcb_tp;
}
/*
* Get the current kcb.
*
* This can only be called while in a critical region; don't
* worry about having the kcb changed out from under us.
*/
static __inline struct kcb *
_kcb_get(void)
{
return (_tcb->tcb_curkcb);
}
/*
* Enter a critical region.
*
* Read and clear km_curthread in the kse mailbox.
*/
static __inline struct kse_thr_mailbox *
_kcb_critical_enter(void)
{
struct kse_thr_mailbox *crit;
uint32_t flags;
if (_tcb->tcb_isfake != 0) {
/*
* We already are in a critical region since
* there is no current thread.
*/
crit = NULL;
} else {
flags = _tcb->tcb_tmbx.tm_flags;
_tcb->tcb_tmbx.tm_flags |= TMF_NOUPCALL;
crit = _tcb->tcb_curkcb->kcb_kmbx.km_curthread;
_tcb->tcb_curkcb->kcb_kmbx.km_curthread = NULL;
_tcb->tcb_tmbx.tm_flags = flags;
}
return (crit);
}
static __inline void
_kcb_critical_leave(struct kse_thr_mailbox *crit)
{
/* No need to do anything if this is a fake tcb. */
if (_tcb->tcb_isfake == 0)
_tcb->tcb_curkcb->kcb_kmbx.km_curthread = crit;
}
static __inline int
_kcb_in_critical(void)
{
uint32_t flags;
int ret;
if (_tcb->tcb_isfake != 0) {
/*
* We are in a critical region since there is no
* current thread.
*/
ret = 1;
} else {
flags = _tcb->tcb_tmbx.tm_flags;
_tcb->tcb_tmbx.tm_flags |= TMF_NOUPCALL;
ret = (_tcb->tcb_curkcb->kcb_kmbx.km_curthread == NULL);
_tcb->tcb_tmbx.tm_flags = flags;
}
return (ret);
}
static __inline void
_tcb_set(struct kcb *kcb, struct tcb *tcb)
{
if (tcb == NULL)
tcb = &kcb->kcb_faketcb;
kcb->kcb_curtcb = tcb;
tcb->tcb_curkcb = kcb;
_tp = &tcb->tcb_tp;
}
static __inline struct tcb *
_tcb_get(void)
{
return (_tcb);
}
static __inline struct pthread *
_get_curthread(void)
{
return (_tcb->tcb_thread);
}
/*
* Get the current kse.
*
* Like _kcb_get(), this can only be called while in a critical region.
*/
static __inline struct kse *
_get_curkse(void)
{
return (_tcb->tcb_curkcb->kcb_kse);
}
void _sparc64_enter_uts(kse_func_t uts, struct kse_mailbox *km, void *stack,
size_t stacksz);
static __inline int
_thread_enter_uts(struct tcb *tcb, struct kcb *kcb)
{
if (_thr_getcontext(&tcb->tcb_tmbx.tm_context.uc_mcontext) == 0) {
/* Make the fake tcb the current thread. */
kcb->kcb_curtcb = &kcb->kcb_faketcb;
_tp = &kcb->kcb_faketcb.tcb_tp;
_sparc64_enter_uts(kcb->kcb_kmbx.km_func, &kcb->kcb_kmbx,
kcb->kcb_kmbx.km_stack.ss_sp,
kcb->kcb_kmbx.km_stack.ss_size);
/* We should not reach here. */
return (-1);
}
return (0);
}
static __inline int
_thread_switch(struct kcb *kcb, struct tcb *tcb, int setmbox)
{
mcontext_t *mc;
_tcb_set(kcb, tcb);
mc = &tcb->tcb_tmbx.tm_context.uc_mcontext;
if (setmbox)
_thr_setcontext(mc, (intptr_t)&tcb->tcb_tmbx,
(intptr_t *)&kcb->kcb_kmbx.km_curthread);
else
_thr_setcontext(mc, 0, NULL);
/* We should not reach here. */
return (-1);
}
#endif /* _PTHREAD_MD_H_ */
-15
View File
@@ -1,15 +0,0 @@
/*
* Offsets into structures used from asm. Must be kept in sync with
* appropriate headers.
*
* $FreeBSD$
*/
#define UC_MCONTEXT 0x40
#define MC_FLAGS 0x0
#define MC_VALID_FLAGS 0x1
#define MC_GLOBAL 0x0
#define MC_OUT 0x40
#define MC_TPC 0xc8
#define MC_TNPC 0xc0
@@ -1,91 +0,0 @@
/*-
* Copyright (C) 2003 Jake Burkholder <jake@freebsd.org>
* Copyright (C) 2003 David Xu <davidxu@freebsd.org>
* Copyright (c) 2001,2003 Daniel Eischen <deischen@freebsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <ucontext.h>
#include "pthread_md.h"
struct tcb *
_tcb_ctor(struct pthread *thread)
{
struct tcb *tcb;
void *addr;
addr = malloc(sizeof(struct tcb) + 63);
if (addr == NULL)
tcb = NULL;
else {
tcb = (struct tcb *)(((uintptr_t)(addr) + 63) & ~63);
bzero(tcb, sizeof(struct tcb));
tcb->tcb_addr = addr;
tcb->tcb_thread = thread;
/* XXX - Allocate tdv/tls */
}
return (tcb);
}
void
_tcb_dtor(struct tcb *tcb)
{
void *addr;
addr = tcb->tcb_addr;
tcb->tcb_addr = NULL;
free(addr);
}
struct kcb *
_kcb_ctor(struct kse *kse)
{
struct kcb *kcb;
kcb = malloc(sizeof(struct kcb));
if (kcb != NULL) {
bzero(kcb, sizeof(struct kcb));
kcb->kcb_faketcb.tcb_isfake = 1;
kcb->kcb_faketcb.tcb_tmbx.tm_flags = TMF_NOUPCALL;
kcb->kcb_curtcb = &kcb->kcb_faketcb;
kcb->kcb_kse = kse;
}
return (kcb);
}
void
_kcb_dtor(struct kcb *kcb)
{
free(kcb);
}
@@ -1,87 +0,0 @@
/*-
* Copyright (C) 2003 Jake Burkholder <jake@freebsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
#include "assym.s"
.weak CNAME(_thr_getcontext)
.set CNAME(_thr_getcontext),CNAME(__thr_getcontext)
ENTRY(__thr_getcontext)
add %o7, 8, %o1
add %o1, 4, %o2
stx %sp, [%o0 + MC_OUT + (6 * 8)]
stx %o1, [%o0 + MC_TPC]
stx %o2, [%o0 + MC_TNPC]
mov MC_VALID_FLAGS, %l0 /* Validate the context. */
stx %l0, [%o0 + MC_FLAGS]
mov 1, %l0
stx %l0, [%o0 + MC_OUT + (0 * 8)] /* return 1 when resumed */
retl
mov 0, %o0 /* return 0 */
END(__thr_getcontext)
.weak CNAME(_thr_setcontext)
.set CNAME(_thr_setcontext),CNAME(__thr_setcontext)
ENTRY(__thr_setcontext)
save %sp, -CCFSZ, %sp
flushw
mov %i0, %l0
mov %i1, %l1
mov %i2, %l2
ldx [%l0 + MC_GLOBAL + (1 * 8)], %g1
ldx [%l0 + MC_GLOBAL + (2 * 8)], %g2
ldx [%l0 + MC_GLOBAL + (3 * 8)], %g3
ldx [%l0 + MC_GLOBAL + (4 * 8)], %g4
ldx [%l0 + MC_GLOBAL + (5 * 8)], %g5
ldx [%l0 + MC_GLOBAL + (6 * 8)], %g6
ldx [%l0 + MC_GLOBAL + (7 * 8)], %g7
ldx [%l0 + MC_OUT + (0 * 8)], %i0
ldx [%l0 + MC_OUT + (1 * 8)], %i1
ldx [%l0 + MC_OUT + (2 * 8)], %i2
ldx [%l0 + MC_OUT + (3 * 8)], %i3
ldx [%l0 + MC_OUT + (4 * 8)], %i4
ldx [%l0 + MC_OUT + (5 * 8)], %i5
ldx [%l0 + MC_OUT + (6 * 8)], %i6
ldx [%l0 + MC_OUT + (7 * 8)], %i7
ldx [%l0 + MC_TPC], %l4
ldx [%l0 + MC_TNPC], %l3
brz %l2, 1f
nop
stx %l1, [%l2]
1: jmpl %l3, %g0
return %l4
END(__thr_setcontext)
ENTRY(_sparc64_enter_uts)
save %sp, -CCFSZ, %sp
flushw
add %i2, %i3, %i2
sub %i2, SPOFF + CCFSZ, %sp
jmpl %i0, %g0
mov %i1, %o0
END(_sparc64_enter_uts)
Loaded 100 of 792 files, more files were not shown because too many files have changed in this diff. Show more