add directory gnu
This commit is contained in:
111
gnu/glibc/glibc-1.03/mach/Machrules
Normal file
111
gnu/glibc/glibc-1.03/mach/Machrules
Normal file
@@ -0,0 +1,111 @@
|
||||
# Rules for MiG interfaces that want to go into the C library.
|
||||
|
||||
# Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
# This file is part of the GNU C Library.
|
||||
|
||||
# The GNU C Library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public License
|
||||
# as published by the Free Software Foundation; either version 2 of
|
||||
# the License, or (at your option) any later version.
|
||||
|
||||
# The GNU C Library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with the GNU C Library; see the file COPYING.LIB. If
|
||||
# not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
# Cambridge, MA 02139, USA.
|
||||
|
||||
# Makefiles define these variable before including this file:
|
||||
# user-interfaces Names of interfaces to put user stubs in for.
|
||||
# server-interfaces Names of interfaces to put server stubs in for.
|
||||
# interface-header-prefix Directory prefix for interface header files.
|
||||
# This file sets:
|
||||
# interface-headers Names of generated interface header files.
|
||||
# interface-routines Names of generated interface routines.
|
||||
# All user stubs are put in individual files, prefixed with __, and a
|
||||
# symbol-alias to the un-__'d form generated; header for both is put in
|
||||
# foo.h. If a server interface is listed as __foo, then its routines are
|
||||
# prefixed with __; server interfaces are written to foo_server.c and
|
||||
# foo_server.h (or __foo_server.c and __foo_server.h).
|
||||
|
||||
# Includers can also add to or modify `migdefines' to set MiG flags.
|
||||
|
||||
all:
|
||||
|
||||
include ../Makeconfig
|
||||
|
||||
# Where to find interface definition files.
|
||||
ifdef MIG_DEFS_PATH
|
||||
vpath %.defs $(MIG_DEFS_PATH)
|
||||
endif
|
||||
|
||||
ifndef MIG
|
||||
MIG = mig
|
||||
endif
|
||||
MIGFLAGS = -DMACH_IPC_COMPAT=0 -DSTANDALONE -DTypeCheck=0 \
|
||||
$(includes) $(migdefines)
|
||||
|
||||
.SUFFIXES: .defs
|
||||
|
||||
define \n
|
||||
|
||||
|
||||
endef
|
||||
ifdef user-interfaces
|
||||
include interface-rules
|
||||
endif
|
||||
interface-rules: Makefile Machrules
|
||||
(for interface in $(user-interfaces); do \
|
||||
echo "include .ir-$${interface}"; \
|
||||
done) > $@-new
|
||||
mv $@-new $@
|
||||
.ir-%: %.uh Machrules
|
||||
(echo 'define $*-calls' ;\
|
||||
awk '/^kern_return_t/ { print $$2 }' $< ;\
|
||||
echo 'endef' ;\
|
||||
echo '$*-calls := $$(subst $$('\\'n), ,$$($*-calls))' ;\
|
||||
echo '$$(patsubst %,foreign-%%c,$$($*-calls:%=__%)): $*.defs' ;\
|
||||
echo ' $$(MIG) < $$< $$(MIGFLAGS) -subrprefix __ -prefix __ -i ./foreign-__')\
|
||||
> $@-new
|
||||
mv $@-new $@
|
||||
vpath Machrules ../mach
|
||||
|
||||
%.c: foreign-%.c
|
||||
(echo '#include <ansidecl.h>'; cat $^) > $@
|
||||
|
||||
# MiG doesn't know how to make separate files for the server stubs.
|
||||
foreign-__%_server.c %_server.h: %.defs
|
||||
$(MIG) < $< $(MIGFLAGS) -subrprefix __ -prefix __ \
|
||||
-user /dev/null -header /dev/null \
|
||||
-server $@ -sheader $(@:__%.c=%.h)
|
||||
foreign-%_server.c %_server.h: %.defs
|
||||
$(MIG) < $< $(MIGFLAGS) -subrprefix __ \
|
||||
-user /dev/null -header /dev/null \
|
||||
-server $@ -sheader $(@:.c=.h)
|
||||
|
||||
%.uh: %.defs
|
||||
$(MIG) < $< $(MIGFLAGS) -subrprefix __ \
|
||||
-header $@ -server /dev/null -user /dev/null
|
||||
%.__h: %.defs
|
||||
$(MIG) < $< $(MIGFLAGS) -subrprefix __ -prefix __ \
|
||||
-header $@ -server /dev/null -user /dev/null
|
||||
|
||||
$(interface-header-prefix)%.h: %.__h %.uh $(interface-header-prefix)
|
||||
# The last line of foo.uh is "#endif _foo_user_".
|
||||
# The first two lines of foo.__h are "#ifndef _foo_user_"/"#define _foo_user_".
|
||||
(sed '$$d' < $<; tail +2 $(word 2,$^)) > $@
|
||||
|
||||
%.c: __%.c
|
||||
(echo '#include <gnu-stabs.h>'; \
|
||||
echo 'symbol_alias (__$*, $*)') > $@
|
||||
|
||||
interface-routines := $(foreach if,$(user-interfaces), \
|
||||
$(calls-$(if)) \
|
||||
$(addprefix __,$(calls-$(if)))) \
|
||||
$(server-interfaces:%=%_server)
|
||||
interface-headers := $(addprefix $(interface-header-prefix),\
|
||||
$(user-interfaces:%=%.h) \
|
||||
$(server-interfaces:%=%_server.h))
|
||||
110
gnu/glibc/glibc-1.03/mach/Makefile
Normal file
110
gnu/glibc/glibc-1.03/mach/Makefile
Normal file
@@ -0,0 +1,110 @@
|
||||
# Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
# This file is part of the GNU C Library.
|
||||
|
||||
# The GNU C Library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public License
|
||||
# as published by the Free Software Foundation; either version 2 of
|
||||
# the License, or (at your option) any later version.
|
||||
|
||||
# The GNU C Library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with the GNU C Library; see the file COPYING.LIB. If
|
||||
# not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
# Cambridge, MA 02139, USA.
|
||||
|
||||
subdir := mach
|
||||
|
||||
distribute = Machrules interface.awk mach-syscalls.awk # $(interfaces:%=%.defs)
|
||||
|
||||
interface-header-prefix = mach/
|
||||
headers = mach_init.h \
|
||||
$(nope mach.h) \
|
||||
$(addprefix mach/,$(mach-headers)) \
|
||||
$(interface-headers)
|
||||
|
||||
ifneq (,)
|
||||
mach-headers := host_info.h kern_return.h \
|
||||
mach_param.h mach_types.h \
|
||||
memory_object.h \
|
||||
message.h mig_errors.h msg_type.h \
|
||||
policy.h port.h processor_info.h \
|
||||
std_types.h task_info.h task_special_ports.h \
|
||||
thread_info.h thread_special_ports.h \
|
||||
thread_status.h thread_switch.h time_value.h \
|
||||
vm_attributes.h vm_inherit.h vm_prot.h \
|
||||
vm_statistics.h
|
||||
|
||||
user-interfaces := mach_interface mach_port mach_host \
|
||||
device device_request device_reply \
|
||||
default_pager_object \
|
||||
memory_object_user memory_object_default
|
||||
server-interfaces := __exc
|
||||
endif
|
||||
|
||||
routines = $(interface-routines) \
|
||||
mach_init mach_init_syms \
|
||||
mig_strncpy mig_support msg \
|
||||
mach_msg_destroy mach_msg_server mach_msg_server_timeout \
|
||||
__mach_msg_destroy __mach_msg_server \
|
||||
devstream
|
||||
|
||||
tests := hello
|
||||
|
||||
|
||||
all:
|
||||
|
||||
|
||||
# Define mach-syscalls and sysno-*.
|
||||
#include mach-syscalls.mk
|
||||
dont_distribute := syscall_sw.h
|
||||
mach-syscalls.mk: syscall_sw.h mach-syscalls.awk
|
||||
sed -n -e '/STANDALONE/,$$d' \
|
||||
-e 's/^kernel_trap(\(.*\),\([-0-9]*\),[0-9]*)$$/\1 \2/p' \
|
||||
< $< | awk -f $(word 2,$^) > $@-new
|
||||
mv $@-new $@
|
||||
|
||||
ifdef mach-syscalls
|
||||
$(mach-syscalls:%=__%.S): __%.S: mach-syscalls.mk
|
||||
(echo '#include <sysdep.h>'; \
|
||||
echo 'SYSCALL_TRAP (__$*, $(sysno-$*))') > $@
|
||||
endif
|
||||
|
||||
mach-shortcuts := $(patsubst syscall_%,%,$(filter syscall_%,$(mach-syscalls)))
|
||||
|
||||
# Make the MiG stubs for $(mach-shortcuts) be CALL_rpc.
|
||||
migdefines := $(migdefines) \
|
||||
$(foreach call,$(mach-shortcuts),-D$(call)=$(call)_rpc)
|
||||
|
||||
# This rule needs to come before the implicit rules in Machrules.
|
||||
__%.c: shortcut.awk __%_rpc.c
|
||||
gawk -v call=__$* -v rpc=__$*_rpc -v syscall=__syscall_$* \
|
||||
-f $^ > $@-new
|
||||
mv $@-new $@
|
||||
|
||||
include Machrules
|
||||
|
||||
interface-routines := $(filter-out %_rpc,$(interface-routines)) \
|
||||
$(foreach call,$(mach-shortcuts),\
|
||||
__$(call) $(call) __syscall_$(call))
|
||||
dont_distribute := $(dont_distribute) \
|
||||
$(interface-routines:%=%.c) $(interface-headers)
|
||||
|
||||
include ../Rules
|
||||
|
||||
|
||||
# There is already a mach.h, so mach.defs generates mach_interface.h.
|
||||
mach_interface.defs: mach.defs
|
||||
ln -s $< $@ || cp $< $@
|
||||
# There is already a memory_object.h,
|
||||
# so memory_object.defs generates memory_object_user.h.
|
||||
memory_object_user.defs: memory_object.defs
|
||||
ln -s $< $@ || cp $< $@
|
||||
|
||||
# Be sure not to make these with implicit rules from foo.defs.
|
||||
ifdef mach-headers
|
||||
$(mach-headers): ;
|
||||
endif
|
||||
147
gnu/glibc/glibc-1.03/mach/__mach_msg_destroy.c
Normal file
147
gnu/glibc/glibc-1.03/mach/__mach_msg_destroy.c
Normal file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Mach Operating System
|
||||
* Copyright (c) 1991,1990 Carnegie Mellon University
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
|
||||
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie Mellon
|
||||
* the rights to redistribute these changes.
|
||||
*/
|
||||
/*
|
||||
* HISTORY
|
||||
* $Log: mach_msg_destroy.c,v $
|
||||
* Revision 2.4 91/05/14 17:53:15 mrt
|
||||
* Correcting copyright
|
||||
*
|
||||
* Revision 2.3 91/02/14 14:17:43 mrt
|
||||
* Added new Mach copyright
|
||||
* [91/02/13 12:44:15 mrt]
|
||||
*
|
||||
* Revision 2.2 90/08/06 17:24:22 rpd
|
||||
* Created.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <mach/port.h>
|
||||
#include <mach/message.h>
|
||||
#include <mach_init.h>
|
||||
|
||||
static void mach_msg_destroy_port();
|
||||
static void mach_msg_destroy_memory();
|
||||
|
||||
/*
|
||||
* Routine: mach_msg_destroy
|
||||
* Purpose:
|
||||
* Deallocates all port rights and out-of-line memory
|
||||
* found in a received message.
|
||||
*/
|
||||
|
||||
void
|
||||
__mach_msg_destroy(msg)
|
||||
mach_msg_header_t *msg;
|
||||
{
|
||||
mach_msg_bits_t mbits = msg->msgh_bits;
|
||||
|
||||
/*
|
||||
* The msgh_local_port field doesn't hold a port right.
|
||||
* The receive operation consumes the destination port right.
|
||||
*/
|
||||
|
||||
mach_msg_destroy_port(msg->msgh_remote_port, MACH_MSGH_BITS_REMOTE(mbits));
|
||||
|
||||
if (mbits & MACH_MSGH_BITS_COMPLEX) {
|
||||
vm_offset_t saddr;
|
||||
vm_offset_t eaddr;
|
||||
|
||||
saddr = (vm_offset_t) (msg + 1);
|
||||
eaddr = (vm_offset_t) msg + msg->msgh_size;
|
||||
|
||||
while (saddr < eaddr) {
|
||||
mach_msg_type_long_t *type;
|
||||
mach_msg_type_name_t name;
|
||||
mach_msg_type_size_t size;
|
||||
mach_msg_type_number_t number;
|
||||
boolean_t is_inline;
|
||||
vm_size_t length;
|
||||
vm_offset_t addr;
|
||||
|
||||
type = (mach_msg_type_long_t *) saddr;
|
||||
is_inline = type->msgtl_header.msgt_inline;
|
||||
if (type->msgtl_header.msgt_longform) {
|
||||
name = type->msgtl_name;
|
||||
size = type->msgtl_size;
|
||||
number = type->msgtl_number;
|
||||
saddr += sizeof(mach_msg_type_long_t);
|
||||
} else {
|
||||
name = type->msgtl_header.msgt_name;
|
||||
size = type->msgtl_header.msgt_size;
|
||||
number = type->msgtl_header.msgt_number;
|
||||
saddr += sizeof(mach_msg_type_t);
|
||||
}
|
||||
|
||||
/* calculate length of data in bytes, rounding up */
|
||||
length = ((((number * size) + 7) >> 3) + 3) &~ 3;
|
||||
|
||||
addr = is_inline ? saddr : * (vm_offset_t *) saddr;
|
||||
|
||||
if (MACH_MSG_TYPE_PORT_ANY(name)) {
|
||||
mach_port_t *ports = (mach_port_t *) addr;
|
||||
mach_msg_type_number_t i;
|
||||
|
||||
for (i = 0; i < number; i++)
|
||||
mach_msg_destroy_port(*ports++, name);
|
||||
}
|
||||
|
||||
if (is_inline) {
|
||||
/* inline data sizes round up to int boundaries */
|
||||
saddr += length;
|
||||
} else {
|
||||
mach_msg_destroy_memory(addr, length);
|
||||
saddr += sizeof(vm_offset_t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
mach_msg_destroy_port(port, type)
|
||||
mach_port_t port;
|
||||
mach_msg_type_name_t type;
|
||||
{
|
||||
if (MACH_PORT_VALID(port)) switch (type) {
|
||||
case MACH_MSG_TYPE_PORT_SEND:
|
||||
case MACH_MSG_TYPE_PORT_SEND_ONCE:
|
||||
(void) __mach_port_deallocate(__mach_task_self(), port);
|
||||
break;
|
||||
|
||||
case MACH_MSG_TYPE_PORT_RECEIVE:
|
||||
(void) __mach_port_mod_refs(__mach_task_self(), port,
|
||||
MACH_PORT_RIGHT_RECEIVE, -1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
mach_msg_destroy_memory(addr, size)
|
||||
vm_offset_t addr;
|
||||
vm_size_t size;
|
||||
{
|
||||
if (size > 0)
|
||||
(void) __vm_deallocate(__mach_task_self(), addr, size);
|
||||
}
|
||||
134
gnu/glibc/glibc-1.03/mach/__mach_msg_server.c
Normal file
134
gnu/glibc/glibc-1.03/mach/__mach_msg_server.c
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Mach Operating System
|
||||
* Copyright (c) 1991,1990 Carnegie Mellon University
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
|
||||
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie Mellon
|
||||
* the rights to redistribute these changes.
|
||||
*/
|
||||
/*
|
||||
* HISTORY
|
||||
* $Log: mach_msg_server.c,v $
|
||||
* Revision 2.4 91/05/14 17:53:22 mrt
|
||||
* Correcting copyright
|
||||
*
|
||||
* Revision 2.3 91/02/14 14:17:47 mrt
|
||||
* Added new Mach copyright
|
||||
* [91/02/13 12:44:20 mrt]
|
||||
*
|
||||
* Revision 2.2 90/08/06 17:23:58 rpd
|
||||
* Created.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <mach/boolean.h>
|
||||
#include <mach/kern_return.h>
|
||||
#include <mach/port.h>
|
||||
#include <mach/message.h>
|
||||
#include <mach/mig_errors.h>
|
||||
|
||||
/*
|
||||
* Routine: mach_msg_server
|
||||
* Purpose:
|
||||
* A simple generic server function.
|
||||
*/
|
||||
|
||||
mach_msg_return_t
|
||||
__mach_msg_server_timeout(demux, max_size, rcv_name, option, timeout)
|
||||
boolean_t (*demux)();
|
||||
mach_msg_size_t max_size;
|
||||
mach_port_t rcv_name;
|
||||
mach_msg_option_t option;
|
||||
mach_msg_timeout_t timeout;
|
||||
{
|
||||
register mig_reply_header_t *bufRequest, *bufReply, *bufTemp;
|
||||
register mach_msg_return_t mr;
|
||||
|
||||
bufRequest = (mig_reply_header_t *) malloc(max_size);
|
||||
if (bufRequest == 0)
|
||||
return KERN_RESOURCE_SHORTAGE;
|
||||
bufReply = (mig_reply_header_t *) malloc(max_size);
|
||||
if (bufReply == 0)
|
||||
return KERN_RESOURCE_SHORTAGE;
|
||||
|
||||
for (;;) {
|
||||
get_request:
|
||||
mr = __mach_msg(&bufRequest->Head, MACH_RCV_MSG|option,
|
||||
0, max_size, rcv_name,
|
||||
timeout, MACH_PORT_NULL);
|
||||
while (mr == MACH_MSG_SUCCESS) {
|
||||
/* we have a request message */
|
||||
|
||||
(void) (*demux)(&bufRequest->Head, &bufReply->Head);
|
||||
|
||||
if (bufReply->RetCode != KERN_SUCCESS) {
|
||||
if (bufReply->RetCode == MIG_NO_REPLY)
|
||||
goto get_request;
|
||||
|
||||
/* don't destroy the reply port right,
|
||||
so we can send an error message */
|
||||
bufRequest->Head.msgh_remote_port = MACH_PORT_NULL;
|
||||
__mach_msg_destroy(&bufRequest->Head);
|
||||
}
|
||||
|
||||
if (bufReply->Head.msgh_remote_port == MACH_PORT_NULL) {
|
||||
/* no reply port, so destroy the reply */
|
||||
if (bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)
|
||||
__mach_msg_destroy(&bufReply->Head);
|
||||
|
||||
goto get_request;
|
||||
}
|
||||
|
||||
/* send reply and get next request */
|
||||
|
||||
bufTemp = bufRequest;
|
||||
bufRequest = bufReply;
|
||||
bufReply = bufTemp;
|
||||
|
||||
mr = __mach_msg(&bufRequest->Head,
|
||||
MACH_SEND_MSG|MACH_RCV_MSG|option,
|
||||
bufRequest->Head.msgh_size, max_size, rcv_name,
|
||||
timeout, MACH_PORT_NULL);
|
||||
}
|
||||
|
||||
/* a message error occurred */
|
||||
|
||||
if (mr != MACH_SEND_INVALID_DEST)
|
||||
break;
|
||||
|
||||
/* the reply can't be delivered, so destroy it */
|
||||
__mach_msg_destroy(&bufRequest->Head);
|
||||
}
|
||||
|
||||
free((char *) bufRequest);
|
||||
free((char *) bufReply);
|
||||
return mr;
|
||||
}
|
||||
|
||||
|
||||
mach_msg_return_t
|
||||
__mach_msg_server (demux, max_size, rcv_name)
|
||||
boolean_t (*demux) ();
|
||||
mach_msg_size_t max_size;
|
||||
mach_port_t rcv_name;
|
||||
{
|
||||
return __mach_msg_server_timeout (demux, max_size, rcv_name,
|
||||
option, MACH_MSG_TIMEOUT_NONE);
|
||||
}
|
||||
168
gnu/glibc/glibc-1.03/mach/devstream.c
Normal file
168
gnu/glibc/glibc-1.03/mach/devstream.c
Normal file
@@ -0,0 +1,168 @@
|
||||
/* stdio on a Mach device port.
|
||||
Translates \n to \r on output.
|
||||
|
||||
Copyright (C) 1992 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <ansidecl.h>
|
||||
#include <stdio.h>
|
||||
#include <mach.h>
|
||||
#include <mach/device.h>
|
||||
|
||||
static int
|
||||
input (FILE *f)
|
||||
{
|
||||
error_t err;
|
||||
char *buffer;
|
||||
size_t to_read;
|
||||
char c;
|
||||
|
||||
if (f->__buffer == NULL)
|
||||
{
|
||||
buffer = &c;
|
||||
to_read = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = f->__buffer;
|
||||
to_read = f->__bufsize;
|
||||
}
|
||||
|
||||
f->__eof = 0;
|
||||
|
||||
if (err = device_read_inband ((device_t) cookie, 0, f->__target, to_read,
|
||||
buffer, &nread))
|
||||
{
|
||||
f->__error = 1;
|
||||
f->__bufp = f->__get_limit = f->__put_limit = f->__buffer;
|
||||
errno = err;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
if (f->__buffer == NULL)
|
||||
return (unsigned char) c;
|
||||
|
||||
f->__get_limit = f->__buffer + nread;
|
||||
f->__bufp = f->__buffer;
|
||||
f->__put_limit = f->__buffer + (f->__mode.__write ? f->__bufsize : 0);
|
||||
return (unsigned char *) *f->__bufp++;
|
||||
}
|
||||
|
||||
static void
|
||||
output (FILE *f, int c)
|
||||
{
|
||||
error_t err;
|
||||
size_t to_write;
|
||||
char *p;
|
||||
|
||||
if (f->__buffer == NULL)
|
||||
{
|
||||
if (c != EOF)
|
||||
{
|
||||
char cc = (unsigned char) c;
|
||||
int wrote;
|
||||
if (cc == '\n')
|
||||
cc = '\r';
|
||||
if ((err = device_write_inband ((device_t) f->__cookie, 0,
|
||||
f->__target, &cc, 1, &wrote)) ||
|
||||
wrote != 1)
|
||||
{
|
||||
errno = err;
|
||||
f->__error = 1;
|
||||
}
|
||||
}
|
||||
++f->__target;
|
||||
return;
|
||||
}
|
||||
|
||||
if (f->__put_limit == f->__buffer)
|
||||
{
|
||||
f->__put_limit = f->__buffer + f->__bufsize;
|
||||
f->__bufp = f->__buffer;
|
||||
if (c != EOF)
|
||||
{
|
||||
*f->__bufp++ = (unsigned char) c;
|
||||
c = EOF;
|
||||
}
|
||||
}
|
||||
|
||||
to_write = f->__bufp - f->__buffer;
|
||||
p = f->__buffer;
|
||||
while (1)
|
||||
{
|
||||
char *p2 = memchr (p, '\n', to_write);
|
||||
if (p2 == NULL)
|
||||
break;
|
||||
*p2++ = '\r';
|
||||
to_write -= p2 - p;
|
||||
p = p2;
|
||||
}
|
||||
|
||||
to_write = f->__bufp - f->__buffer;
|
||||
p = f->__buffer;
|
||||
while (to_write > 0)
|
||||
{
|
||||
int wrote;
|
||||
if (err = device_write_inband ((device_t) f->__cookie, 0, f->__target,
|
||||
p, to_write, &wrote))
|
||||
{
|
||||
errno = EIO;
|
||||
f->__error = 1;
|
||||
break;
|
||||
}
|
||||
p += wrote;
|
||||
to_write -= wrote;
|
||||
f->__target += wrote;
|
||||
}
|
||||
|
||||
f->__bufp = f->__buffer;
|
||||
|
||||
if (c != EOF && !ferror (f))
|
||||
{
|
||||
if (f->__linebuf && (unsigned char) c == '\n')
|
||||
{
|
||||
static const char nl = '\r';
|
||||
if ((err = device_write_inband ((device_t) f->__cookie, 0,
|
||||
f->__target, &nl, 1, &wrote)) ||
|
||||
wrote != 1)
|
||||
{
|
||||
errno = EIO;
|
||||
f->__error = 1;
|
||||
}
|
||||
else
|
||||
++f->__target;
|
||||
}
|
||||
else
|
||||
*f->__bufp++ = (unsigned char) c;
|
||||
}
|
||||
}
|
||||
|
||||
FILE *
|
||||
mach_open_devstream (device_t dev, const char *mode)
|
||||
{
|
||||
FILE *stream = fopencookie (dev, mode, __default_io_functions);
|
||||
if (stream == NULL)
|
||||
return NULL;
|
||||
|
||||
stream->__room_funcs.__input = input;
|
||||
stream->__room_funcs.__output = output;
|
||||
stream->__io_funcs.__close = device_close;
|
||||
stream->__seen = 1;
|
||||
|
||||
retrun stream;
|
||||
}
|
||||
48
gnu/glibc/glibc-1.03/mach/hello.c
Normal file
48
gnu/glibc/glibc-1.03/mach/hello.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/* "Hello world" program for GNU C Library on bare Mach 3.0.
|
||||
|
||||
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <ansidecl.h>
|
||||
#include <mach.h>
|
||||
#include <mach/device.h>
|
||||
#include <errno.h>
|
||||
|
||||
extern FILE *mach_open_devstream (device_t dev);
|
||||
|
||||
int
|
||||
main (int argc, char **argv, char **envp)
|
||||
{
|
||||
error_t err;
|
||||
mach_port_t device, consdev;
|
||||
FILE *consf;
|
||||
|
||||
device = pid2task (-2);
|
||||
err = device_open (device, D_WRITE, "console", &consdev);
|
||||
mach_port_deallocate (mach_task_self (), device);
|
||||
if (err)
|
||||
exit (err);
|
||||
|
||||
consf = mach_open_devstream (consdev);
|
||||
if (consf == NULL)
|
||||
exit (errno);
|
||||
|
||||
fputs ("Hello, world!\n", consf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
22
gnu/glibc/glibc-1.03/mach/interface.awk
Normal file
22
gnu/glibc/glibc-1.03/mach/interface.awk
Normal file
@@ -0,0 +1,22 @@
|
||||
BEGIN { wantcall=0; calls=""; }
|
||||
|
||||
NF == 1 && ($1 == "routine" || $1 == "simpleroutine") \
|
||||
{ wantcall=1; next; }
|
||||
|
||||
wantcall == 0 && NF >= 2 && ($1 == "routine" || $1 == "simpleroutine") \
|
||||
{
|
||||
if (substr($2, length($2)-2, 1) == "(")
|
||||
calls = calls " " substr($2, 0, length($2)-1);
|
||||
else calls = calls " " $2;
|
||||
}
|
||||
|
||||
wantcall == 1 && NF >= 1 \
|
||||
{
|
||||
if (substr($1, length($1)-2, 1) == "(")
|
||||
calls = calls " " substr($1, 0, length($1)-1);
|
||||
else calls = calls " " $1;
|
||||
}
|
||||
|
||||
{ wantcall=0; }
|
||||
|
||||
END { print varname " :=" calls; }
|
||||
8
gnu/glibc/glibc-1.03/mach/mach-syscalls.awk
Normal file
8
gnu/glibc/glibc-1.03/mach/mach-syscalls.awk
Normal file
@@ -0,0 +1,8 @@
|
||||
BEGIN { calls="" }
|
||||
|
||||
{
|
||||
calls = calls " " $1;
|
||||
print "sysno-" $1 " = " $2;
|
||||
}
|
||||
|
||||
END { print "mach-syscalls := " calls }
|
||||
38
gnu/glibc/glibc-1.03/mach/mach_init.c
Normal file
38
gnu/glibc/glibc-1.03/mach/mach_init.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/* Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <mach_init.h>
|
||||
|
||||
extern void __mig_init (int);
|
||||
|
||||
mach_port_t __mach_task_self_;
|
||||
vm_size_t __vm_page_size;
|
||||
|
||||
void
|
||||
__mach_init (void)
|
||||
{
|
||||
error_t err;
|
||||
vm_statistics_data_t stats;
|
||||
|
||||
__mach_task_self_ = (__mach_task_self) ();
|
||||
__mig_init (0);
|
||||
|
||||
if (err = __vm_statistics (__mach_task_self (), &stats))
|
||||
_exit (err);
|
||||
__vm_page_size = stats.pagesize;
|
||||
}
|
||||
26
gnu/glibc/glibc-1.03/mach/mach_init.h
Normal file
26
gnu/glibc/glibc-1.03/mach/mach_init.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef _MACH_INIT_H
|
||||
|
||||
#define _MACH_INIT_H 1
|
||||
|
||||
#include <mach/mach_types.h>
|
||||
|
||||
/* Return the current task's task port. */
|
||||
extern mach_port_t __mach_task_self (void);
|
||||
|
||||
/* This cache is initialized at startup. */
|
||||
extern mach_port_t __mach_task_self_;
|
||||
#define mach_task_self() __mach_task_self_
|
||||
|
||||
/* Kernel page size.. */
|
||||
extern vm_size_t __vm_page_size;
|
||||
|
||||
/* Round the address X up to a page boundary. */
|
||||
#define round_page(x) \
|
||||
((((vm_offset_t) (x) + __vm_page_size - 1) / __vm_page_size) * \
|
||||
__vm_page_size)
|
||||
|
||||
/* Truncate the address X down to a page boundary. */
|
||||
#define trunc_page(x) \
|
||||
((((vm_offset_t) (x)) / __vm_page_size) * __vm_page_size)
|
||||
|
||||
#endif /* mach_init.h */
|
||||
3
gnu/glibc/glibc-1.03/mach/mach_init_syms.c
Normal file
3
gnu/glibc/glibc-1.03/mach/mach_init_syms.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#include <gnu-stabs.h>
|
||||
|
||||
symbol_alias (__vm_page_size, vm_page_size);
|
||||
4
gnu/glibc/glibc-1.03/mach/mach_msg_destroy.c
Normal file
4
gnu/glibc/glibc-1.03/mach/mach_msg_destroy.c
Normal file
@@ -0,0 +1,4 @@
|
||||
#include <gnu-stabs.h>
|
||||
|
||||
#undef mach_msg_destroy
|
||||
symbol_alias (__mach_msg_destroy, mach_msg_destroy);
|
||||
4
gnu/glibc/glibc-1.03/mach/mach_msg_server.c
Normal file
4
gnu/glibc/glibc-1.03/mach/mach_msg_server.c
Normal file
@@ -0,0 +1,4 @@
|
||||
#include <gnu-stabs.h>
|
||||
|
||||
#undef mach_msg_server
|
||||
symbol_alias (__mach_msg_server, mach_msg_server);
|
||||
4
gnu/glibc/glibc-1.03/mach/mach_msg_server_timeout.c
Normal file
4
gnu/glibc/glibc-1.03/mach/mach_msg_server_timeout.c
Normal file
@@ -0,0 +1,4 @@
|
||||
#include <gnu-stabs.h>
|
||||
|
||||
#undef mach_msg_server_timeout
|
||||
symbol_alias (__mach_msg_server_timeout, mach_msg_server_timeout);
|
||||
20
gnu/glibc/glibc-1.03/mach/mig_strncpy.c
Normal file
20
gnu/glibc/glibc-1.03/mach/mig_strncpy.c
Normal file
@@ -0,0 +1,20 @@
|
||||
/* Silly pointless function MiG needs. */
|
||||
|
||||
#include <ansidecl.h>
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
__mig_strncpy (char *dest, char *src, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
for (i = 1; i < len; ++i)
|
||||
if ((*dest++ = *src++) == '\0')
|
||||
return i;
|
||||
|
||||
*dest = '\0';
|
||||
return i;
|
||||
}
|
||||
31
gnu/glibc/glibc-1.03/mach/mig_support.c
Normal file
31
gnu/glibc/glibc-1.03/mach/mig_support.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <mach/mach.h>
|
||||
|
||||
static mach_port_t reply_port;
|
||||
|
||||
/* Called at startup with NOP==0. */
|
||||
void
|
||||
__mig_init (int nop)
|
||||
{
|
||||
if (!nop)
|
||||
reply_port = MACH_PORT_NULL;
|
||||
}
|
||||
|
||||
/* Called by MiG to get a reply port. */
|
||||
mach_port_t
|
||||
__mig_get_reply_port (void)
|
||||
{
|
||||
if (reply_port == MACH_PORT_NULL)
|
||||
reply_port = __mach_reply_port ();
|
||||
|
||||
return reply_port;
|
||||
}
|
||||
|
||||
/* Called by MiG to deallocate the reply port. */
|
||||
mach_port_t
|
||||
__mig_dealloc_reply_port (void)
|
||||
{
|
||||
mach_port_t port = reply_port;
|
||||
reply_port = MACH_PORT_NULL; /* So the mod_refs RPC won't use it. */
|
||||
__mach_port_mod_refs (__mach_task_self (), port,
|
||||
MACH_PORT_RIGHT_RECEIVE, -1);
|
||||
}
|
||||
79
gnu/glibc/glibc-1.03/mach/msg.c
Normal file
79
gnu/glibc/glibc-1.03/mach/msg.c
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Mach Operating System
|
||||
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
|
||||
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie Mellon
|
||||
* the rights to redistribute these changes.
|
||||
*/
|
||||
#include <mach/port.h>
|
||||
#include <mach/message.h>
|
||||
|
||||
mach_msg_return_t
|
||||
__mach_msg (mach_msg_header_t *msg,
|
||||
mach_msg_option_t option,
|
||||
mach_msg_size_t send_size,
|
||||
mach_msg_size_t rcv_size,
|
||||
mach_port_t rcv_name,
|
||||
mach_msg_timeout_t timeout,
|
||||
mach_port_t notify)
|
||||
{
|
||||
mach_msg_return_t ret;
|
||||
|
||||
/* Consider the following cases:
|
||||
1. Errors in pseudo-receive (eg, MACH_SEND_INTERRUPTED
|
||||
plus special bits).
|
||||
2. Use of MACH_SEND_INTERRUPT/MACH_RCV_INTERRUPT options.
|
||||
3. RPC calls with interruptions in one/both halves.
|
||||
*/
|
||||
|
||||
ret = __mach_msg_trap (msg, option, send_size,
|
||||
rcv_size, rcv_name, timeout, notify);
|
||||
if (ret == MACH_MSG_SUCCESS)
|
||||
return MACH_MSG_SUCCESS;
|
||||
|
||||
if (!(option & MACH_SEND_INTERRUPT))
|
||||
while (ret == MACH_SEND_INTERRUPTED)
|
||||
ret = __mach_msg_trap (msg, option, send_size,
|
||||
rcv_size, rcv_name, timeout, notify);
|
||||
|
||||
if (!(option & MACH_RCV_INTERRUPT))
|
||||
while (ret == MACH_RCV_INTERRUPTED)
|
||||
ret = __mach_msg_trap (msg, option & ~MACH_SEND_MSG,
|
||||
0, rcv_size, rcv_name, timeout, notify);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
mach_msg_return_t
|
||||
__mach_msg_send (mach_msg_header_t *msg)
|
||||
{
|
||||
return __mach_msg (msg, MACH_SEND_MSG,
|
||||
msg->msgh_size, 0, MACH_PORT_NULL,
|
||||
MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
|
||||
}
|
||||
|
||||
mach_msg_return_t
|
||||
__mach_msg_receive (mach_msg_header_t *msg)
|
||||
{
|
||||
return __mach_msg (msg, MACH_RCV_MSG,
|
||||
0, msg->msgh_size, msg->msgh_local_port,
|
||||
MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
|
||||
}
|
||||
Reference in New Issue
Block a user