URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
Compare Revisions
- This comparison shows the changes necessary to convert path
/or1k/trunk/uclinux/uC-libc/sysdeps/m68k
- from Rev 199 to Rev 1765
- ↔ Reverse comparison
Rev 199 → Rev 1765
/__setfpucw.c
0,0 → 1,36
/* Copyright (C) 1993 Olaf Flebbe |
This file is part of the Linux C Library. |
|
The Linux 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 Linux 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. */ |
|
#include <fpu_control.h> |
|
void |
__setfpucw(unsigned long fpu_control) |
{ |
unsigned long fpcr; |
|
/* If user supplied _fpu_control, use it ! */ |
if (!fpu_control) |
{ |
/* use linux defaults */ |
fpu_control = _FPU_DEFAULT; |
} |
/* Get Floating Point Control Register */ |
__asm__ volatile ("fmovel %!,%0" : "=g" (fpcr) : ); |
|
/* mask in */ |
fpcr &= _FPU_RESERVED; |
fpcr = fpcr | (fpu_control & ~_FPU_RESERVED); |
|
/* set Control Register */ |
__asm__ volatile ("fmovel %0,%!" : : "g" (fpcr)); |
} |
/____sig.S
0,0 → 1,30
#ifdef __ELF__ |
#define ____sig_restore ___sig_restore |
#define ____masksig_restore ___masksig_restore |
#define ___sigsetmask __sigsetmask |
#endif |
|
.globl ____sig_restore |
.globl ____masksig_restore |
|
____sig_restore: |
addql #4,%sp | signr |
rts |
#ifdef __ELF__ |
.type ___sig_restore,@function |
.size ___sig_restore,.-___sig_restore |
#endif |
|
____masksig_restore: |
addql #4,%sp | signr |
#if defined(__PIC__) || defined(__pic__) |
bsrl ___sigsetmask@PLTPC | old blocking |
#else |
jbsr ___sigsetmask | old blocking |
#endif |
addql #4,%sp |
rts |
#ifdef __ELF__ |
.type ___masksig_restore,@function |
.size ___masksig_restore,.-___masksig_restore |
#endif |
/__sbrk.c
0,0 → 1,30
#include <unistd.h> |
#include <sys/syscall.h> |
#include <errno.h> |
|
extern void * ___brk_addr; |
|
extern int __init_brk (void); |
|
void * |
__sbrk(ptrdiff_t increment) |
{ |
if (__init_brk () == 0) |
{ |
register void * tmp asm ("%d1") = ___brk_addr+increment; |
__asm__ volatile ("movel %1,%/d0\n\t" |
"trap #0\n\t" |
"movel %/d0,%0" |
:"=g" (___brk_addr) |
:"i" (SYS_brk),"g" (tmp) : "%d0"); |
if (___brk_addr == tmp) |
return tmp-increment; |
errno = ENOMEM; |
} |
return ((void *) -1); |
} |
|
#include <gnu-stabs.h> |
#ifdef weak_alias |
weak_alias (__sbrk, sbrk); |
#endif |
/__open.c
0,0 → 1,28
#include <fcntl.h> |
#include <errno.h> |
#include <sys/syscall.h> |
#include <stdarg.h> |
|
int |
__open(const char * filename, int flag, ...) |
{ |
int res; |
register int d0 asm ("%d0"); |
va_list arg; |
|
va_start(arg,flag); |
__asm__("movel %2,%/d1\n\t" |
"movel %3,%/d2\n\t" |
"movel %4,%/d3\n\t" |
"trap #0\n\t" |
:"=g" (d0) |
:"0" (SYS_open),"g" (filename),"g" (flag), |
"g" (va_arg(arg,int)) |
: "%d0", "%d1", "%d2", "%d3"); |
res = d0; |
if (res>=0) |
return res; |
errno = -res; |
va_end(arg); |
return -1; |
} |
/__init_brk.c
0,0 → 1,29
#include <unistd.h> |
#include <sys/syscall.h> |
#include <errno.h> |
#include <gnu-stabs.h> |
|
void *___brk_addr = 0; |
|
int |
__init_brk (void) |
{ |
if (___brk_addr == 0) |
{ |
register void *tmp asm ("%d1") = 0; |
__asm__ volatile ("movel %1,%/d0\n\t" |
"trap #0\n\t" |
"movel %/d0,%0" |
: "=g" (___brk_addr) |
: "i" (SYS_brk), "g" (tmp) |
: "%d0"); |
if (___brk_addr == 0) |
{ |
errno = ENOMEM; |
return -1; |
} |
} |
return 0; |
} |
|
weak_alias (___brk_addr, __curbrk); |
/libc_exit.c
0,0 → 1,21
#include <unistd.h> |
#include <sys/syscall.h> |
|
#ifdef PTHREAD_KERNEL |
#pragma weak machdep_sys__exit = __machdep_sys__exit |
|
void |
__machdep_sys__exit(int exit_code) |
#else /* PTHREAD_KERNEL */ |
|
#ifdef _POSIX_THREADS |
#pragma weak _exit |
#endif |
|
void |
_exit(int exit_code) |
#endif /* PTHREAD_KERNEL */ |
{ |
__asm__ volatile ("moveq %0,%/d0;movel %1,%/d1;trap #0" |
::"i" (SYS_exit),"g" (exit_code) : "%d0", "%d1"); |
} |
/__fcntl.c
0,0 → 1,27
#include <fcntl.h> |
#include <errno.h> |
#include <sys/syscall.h> |
#include <stdarg.h> |
|
int |
__fcntl(int fildes, int cmd, ...) |
{ |
int res; |
register int d0 asm ("%d0"); |
va_list arg; |
|
va_start(arg,cmd); |
__asm__("movel %2,%/d1\n\t" |
"movel %3,%/d2\n\t" |
"movel %4,%/d3\n\t" |
"trap #0\n\t" |
:"=g" (d0) |
:"0" (SYS_fcntl),"g" (fildes),"g" (cmd), "d" (va_arg(arg,int)) |
: "%d0", "%d1", "%d2", "%d3"); |
res = d0; |
if (res>=0) |
return res; |
errno = -res; |
va_end (arg); |
return -1; |
} /* */ |
/ieee.c
0,0 → 1,3
#include <fpu_control.h> |
|
unsigned long __fpu_control = _FPU_IEEE; |
/crt/gcrt0.S
0,0 → 1,185
/* |
* Copyright (c) 1993 Eric Youngdale, Peter MacDonald, David Engel |
* and Hongjiu Lu. |
* |
* 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. The name of the above contributors may not be |
* used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE 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 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. |
*/ |
|
/* Notice of general intent: |
* |
* The linux operating system generally contains large amounts of code |
* that fall under the GNU General Public License, or GPL for short. |
* This file contains source code that by it's very nature would always |
* be linked with an application program, and because of this a GPL type |
* of copyright on this file would place restrictions upon the |
* distribution of binary-only commercial software. Since the goal of the |
* Linux project as a whole is not to discourage the development and |
* distribution of commercial software for Linux, this file has been placed |
* under a more relaxed BSD-style of copyright. |
* |
* It is the general understanding of the above contributors that a |
* program executable linked to a library containing code that falls |
* under the GPL or GLPL style of license is not subject to the terms of |
* the GPL or GLPL license if the program executable(s) that are supplied |
* are linked to a shared library form of the GPL or GLPL library, and as long |
* as the form of the shared library is such that it is possible for |
* the end user to modify and rebuild the library and use it in |
* conjunction with the program executable. |
*/ |
|
#ifdef __ELF__ |
#define _main main |
#define _atexit atexit |
#define _exit exit |
#define ___libc_init __libc_init |
#define _setlocale setlocale |
#define ___setfpucw __setfpucw |
#define ___fpu_control __fpu_control |
#define ___environ __environ |
#define ____brk_addr ___brk_addr |
#define _monstartup monstartup |
#define __mcleanup _mcleanup |
#define __entry _start |
#define d0 %D0 |
#define d1 %D1 |
#define a0 %A0 |
#define sp %SP |
#endif |
|
.file "gcrt0.S" |
|
#if defined (__ELF__) && defined (CALL_DEFAULT_LOCALE) |
.section .rodata |
.align 4 |
.type ___null_string,@object |
.size ___null_string,4 |
___null_string: |
.long .L_shared_dummy__ |
.L_shared_dummy__: |
.asciz "" |
#endif |
|
.text |
___crt_dummy__: |
#ifndef __ELF__ |
__entry: |
/* |
* The first thing we do is try to load the shared library. If that |
* fails, it won't return. |
*/ |
jbsr ___load_shared_libraries |
#else |
/* ELF stuff here */ |
.globl _start |
.type _start,@function |
_start: |
/* First locate the start of the environment variables */ |
movel sp@+,d0 |
movel sp,a0 |
pea sp@(4,d0:l:4) |
movel a0,sp@- |
movel d0,sp@- |
#endif |
#if 0 |
/* |
* This is important, and was missing from the new version... |
*/ |
moveq #45,d0 |
moveq #0,d1 |
trap #0 |
movel d0,____brk_addr |
#endif |
/* |
* Setup profiling |
*/ |
pea __mcleanup |
jbsr _atexit |
addql #4,sp |
pea _etext |
pea __entry |
jbsr _monstartup |
addql #8,sp |
/* |
* Setup ___environ and call _main |
*/ |
movel sp@(8),___environ |
movel ___fpu_control,sp@- |
jbsr ___setfpucw |
addql #4,sp |
/* Some functions may be needed. */ |
jbsr ___libc_init |
#ifdef CALL_DEFAULT_LOCALE |
/* Set up the default locale */ |
movel ___null_string,sp@- |
pea DEFAULT_LOCALE |
jbsr _setlocale |
addql #8,sp |
#endif |
#ifdef ELF_INIT_FINI |
pea _fini |
jbsr atexit |
addql #4,sp |
jbsr _init |
#endif |
jbsr _main |
movel d0,sp@- |
jbsr _exit |
/* |
* Just in case _exit fails... We use trap #0 for __exit(). |
*/ |
addql #4,sp |
done: |
moveq #1,d0 |
trap #0 |
bras done |
|
#ifdef __ELF__ |
.size _start,.-_start |
.globl __environ |
.data |
.type __environ,@object |
.align 4 |
__environ: |
.long 0 |
.size __environ,4 |
.weak environ |
environ = __environ |
#else |
.align 2 |
#ifdef CALL_DEFAULT_LOCALE |
___null_string: |
.long ___shared_dummy__ |
#endif |
___shared_dummy__: |
.asciz "" |
.stabs "___SHARED_LIBRARIES__",25,0,0,___shared_dummy__ |
|
.data |
.align 2 |
___shared_dummy1__: |
.long 0xfeeb1ed3 /* Magic number used by DLL code to make sure this |
is a real list */ |
|
.stabs "__SHARABLE_CONFLICTS__",25,0,0,___shared_dummy1__ |
#endif |
/crt/gcrt1.S
0,0 → 1,2
#define ELF_INIT_FINI |
#include "gcrt0.S" |
/crt/crti.S
0,0 → 1,11
.section .init |
.globl _init |
.type _init,@function |
.align 4 |
_init: |
|
.section .fini |
.globl _fini |
.type _fini,@function |
.align 4 |
_fini: |
/crt/defaultlocale.c
0,0 → 1,3
#include <locale.h> |
|
DEFAULT_LOCALE:LC_ALL |
/crt/crtn.S
0,0 → 1,9
# This file contains stuff that goes at the end of the .init and .fini |
# sections. The idea is that the linker simply strings together the init |
# sections from the various input files, and this end up at the end. |
|
.section .init |
rts |
|
.section .fini |
rts |
/crt/crt0.S
0,0 → 1,188
/* |
* Copyright (c) 1993 Eric Youngdale, Peter MacDonald, David Engel |
* and Hongjiu Lu. |
* |
* 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. The name of the above contributors may not be |
* used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE 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 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. |
*/ |
|
/* Notice of general intent: |
* |
* The linux operating system generally contains large amounts of code |
* that fall under the GNU General Public License, or GPL for short. |
* This file contains source code that by it's very nature would always |
* be linked with an application program, and because of this a GPL type |
* of copyright on this file would place restrictions upon the |
* distribution of binary-only commercial software. Since the goal of the |
* Linux project as a whole is not to discourage the development and |
* distribution of commercial software for Linux, this file has been placed |
* under a more relaxed BSD-style of copyright. |
* |
* It is the general understanding of the above contributors that a |
* program executable linked to a library containing code that falls |
* under the GPL or GLPL style of license is not subject to the terms of |
* the GPL or GLPL license if the program executable(s) that are supplied |
* are linked to a shared library form of the GPL or GLPL library, and as long |
* as the form of the shared library is such that it is possible for |
* the end user to modify and rebuild the library and use it in |
* conjunction with the program executable. |
*/ |
|
#ifdef __ELF__ |
#define _main main |
#define _exit exit |
#define ___libc_init __libc_init |
#define _setlocale setlocale |
#define ___setfpucw __setfpucw |
#define ___fpu_control __fpu_control |
#define ___environ __environ |
#define ____brk_addr ___brk_addr |
#define d0 %D0 |
#define d1 %D1 |
#define a0 %A0 |
#define sp %SP |
#endif |
|
.file "crt0.S" |
|
#if defined (__ELF__) && defined (CALL_DEFAULT_LOCALE) |
.section .rodata |
.align 4 |
.type ___null_string,@object |
.size ___null_string,4 |
___null_string: |
.long .L_shared_dummy__ |
.L_shared_dummy__: |
.asciz "" |
#endif |
|
.text |
.globl ___crt_dummy__ |
___crt_dummy__: |
#ifndef __ELF__ |
__entry: |
/* |
* The first thing we do is try to load the shared library. If that |
* fails, it won't return. |
*/ |
jbsr ___load_shared_libraries |
#else |
/* ELF stuff here */ |
.globl _start |
.type _start,@function |
_start: |
/* First locate the start of the environment variables */ |
movel sp@+,d0 |
movel sp,a0 |
pea sp@(4,d0:l:4) |
movel a0,sp@- |
movel d0,sp@- |
/* |
* Make sure we are using the linux personality. |
*/ |
movel #136,d0 |
clrl d1 |
trap #0 |
#endif |
|
#if 0 |
/* |
* This is important, and was missing from the new version... |
*/ |
moveq #45,d0 |
moveq #0,d1 |
trap #0 |
movel d0,____brk_addr |
#endif |
/* |
* ok, set up the ___environ and call _main |
*/ |
movel sp@(8),___environ |
/* Avoid touching the fpu unless necessary. */ |
movel ___fpu_control,d0 |
movel d0,d1 |
andw #0xfff0,d1 |
jeq 1f |
movel d0,sp@- |
jbsr ___setfpucw |
addql #4,sp |
1: |
/* Some functions may be needed. */ |
jbsr ___libc_init |
#ifdef CALL_DEFAULT_LOCALE |
/* Set up the default locale */ |
movel ___null_string,sp@- |
pea DEFAULT_LOCALE |
jbsr _setlocale |
addql #8,sp |
#endif |
#ifdef ELF_INIT_FINI |
pea _fini |
jbsr atexit |
addql #4,sp |
jbsr _init |
#endif |
jbsr _main |
movel d0,sp@- |
jbsr _exit |
/* |
* Just in case _exit fails... We use trap #0 for __exit(). |
*/ |
addql #4,sp |
done: |
moveq #1,d0 |
trap #0 |
bras done |
|
#ifdef __ELF__ |
.align 4 |
.size _start,.-_start |
#if 1 |
.data |
.globl __environ |
.type __environ,@object |
.align 4 |
__environ: |
.long 0 |
.size __environ,4 |
.weak environ |
environ = __environ |
#endif |
#else |
.align 2 |
#ifdef CALL_DEFAULT_LOCALE |
___null_string: |
.long ___shared_dummy__ |
#endif |
___shared_dummy__: |
.asciz "" |
.stabs "___SHARED_LIBRARIES__",25,0,0,___shared_dummy__ |
|
.data |
.align 2 |
___shared_dummy1__: |
.long 0xfeeb1ed3 /* Magic number used by DLL code to make sure this |
is a real list */ |
|
.stabs "__SHARABLE_CONFLICTS__",25,0,0,___shared_dummy1__ |
#endif |
/crt/crt1.S
0,0 → 1,2
#define ELF_INIT_FINI |
#include "crt0.S" |
/crt/Makefile
0,0 → 1,69
# |
# Makefile for crt0.o of Linux |
# |
# |
|
LD=true |
MV=true |
override STATIC_SHARED=false |
override SHARED=false |
override DEBUG=false |
|
TOPDIR=../../../.. |
|
include $(TOPDIR)/Makeconfig |
include $(TOPDIR)/Makerules |
|
CFLAGS=-DDEFAULT_LOCALE="`$(CC) -E defaultlocale.c | grep DEFAULT_LOCALE | sed -e 's/^[^:]*://' -e 's/|/+/g'`" |
PIC_CFLAGS=$(CFLAGS) |
SHARED_CFLAGS=$(CFLAGS) |
DEBUG_CFLAGS=$(CFLAGS) |
|
PROFILE_CFLAGS=$(CFLAGS) |
CHECKER_CFLAGS=$(CFLAGS) |
CC = $(REALCC) |
|
SRCS= defaultlocale.c |
|
ifeq ($(ELF),true) |
|
lib:: $(ELF_SHARED_DIR)/crt1.o \ |
$(ELF_SHARED_DIR)/crti.o $(ELF_SHARED_DIR)/crtn.o \ |
$(ELF_PROFILE_DIR)/gcrt1.o |
|
$(ELF_SHARED_DIR)/crt1.o: crt1.S crt0.S |
$(ELF_PROFILE_DIR)/gcrt1.o: gcrt1.S gcrt0.S |
|
else |
|
ifeq ($(CHECKER),true) |
lib:: $(CHECKER_DIR)/chkrcrt0.o |
endif |
|
ifeq ($(PROFILE),true) |
lib:: $(PROFILE_DIR)/gcrt0.o |
endif |
|
ifeq ($(STATIC),true) |
lib:: $(STATIC_DIR)/crt0.o |
endif |
|
endif |
|
|
lib:: |
@true |
|
realclean clean: |
$(RM) -f core *.s *.o *.a tmp_make foo |
|
depend: |
$(CC) -M $(SRCS) | \ |
sed -e 's,^[ ]*\(.*\.o\)[ ]*:,$(STATIC_DIR)/crt0.o $(PROFILE_DIR)/gcrt0.o $(ELF_SHARED_DIR)/crt1.o $(ELF_PROFILE_DIR)/gcrt1.o $(CHECKER_DIR)/checkcrt0.o:,' > .depend |
|
# |
# include a dependency file if one exists |
# |
ifeq (.depend,$(wildcard .depend)) |
include .depend |
endif |
/__sigact.c
0,0 → 1,71
#include <syscall.h> |
#include <signal.h> |
#include <errno.h> |
|
extern void ___sig_restore(); |
extern void ___masksig_restore(); |
|
#ifdef PTHREAD_KERNEL |
|
#pragma weak machdep_sys_sigaction = __machdep_sys_sigaction |
|
int |
__machdep_sys_sigaction (int sig, struct sigaction *new, struct sigaction *old) |
{ |
if (new) |
{ |
if (new->sa_flags & SA_NOMASK) |
new->sa_restorer = ___sig_restore; |
else |
new->sa_restorer = ___masksig_restore; |
} |
|
__asm__ ("movel %1,%/d0\n\t" |
"movel %2,%/d1\n\t" |
"movel %3,%/d2\n\t" |
"movel %4,%/d3\n\t" |
"trap #0\n\t" |
"movel %/d0,%0" |
: "=g" (sig) |
: "i" (SYS_sigaction), "g" (sig), "g" (new), "g" (old) |
: "%d0", "%d1", "%d2", "%d3"); |
return sig; |
} |
|
#else /* PTHREAD_KERNEL */ |
|
#ifdef _POSIX_THREADS |
#pragma weak __sigaction |
#endif |
|
int |
__sigaction(int sig,struct sigaction * new, struct sigaction * old) |
{ |
if (new) { |
if (new->sa_flags & SA_NOMASK) |
new->sa_restorer=___sig_restore; |
else |
new->sa_restorer=___masksig_restore; |
} |
|
__asm__("movel %1,%/d0\n\t" |
"movel %2,%/d1\n\t" |
"movel %3,%/d2\n\t" |
"movel %4,%/d3\n\t" |
"trap #0\n\t" |
"movel %/d0,%0" |
: "=g" (sig) |
:"i" (SYS_sigaction), "g" (sig), "g" (new), "g" (old) |
: "%d0", "%d1", "%d2", "%d3"); |
if (sig>=0) |
return 0; |
errno = -sig; |
return -1; |
} |
|
#include <gnu-stabs.h> |
#ifdef weak_alias |
weak_alias (__sigaction, sigaction); |
#endif |
|
#endif /* PTHREAD_KERNEL */ |
/__ioctl.c
0,0 → 1,27
#include <errno.h> |
#include <sys/ioctl.h> |
#include <sys/syscall.h> |
#include <stdarg.h> |
|
int |
__ioctl(int fildes, int cmd, ...) |
{ |
int res; |
register int d0 asm ("%d0"); |
va_list arg; |
|
va_start(arg,cmd); |
__asm__("movel %2,%/d1\n\t" |
"movel %3,%/d2\n\t" |
"movel %4,%/d3\n\t" |
"trap #0\n\t" |
:"=g" (d0) |
:"0" (SYS_ioctl),"g" (fildes),"g" (cmd), "g" (va_arg(arg,int)) |
: "%d0", "%d1", "%d2", "%d3"); |
res = d0; |
if (res>=0) |
return res; |
errno = -res; |
va_end(arg); |
return -1; |
} |
/getprio.c
0,0 → 1,24
#include <errno.h> |
#include <sys/resource.h> |
#include <sys/syscall.h> |
|
#define PZERO 15 |
|
int |
getpriority(int which, int who) |
{ |
register long res asm ("%d0") = SYS_getpriority; |
|
__asm__ volatile ("movel %2,%/d1\n\t" |
"movel %3,%/d2\n\t" |
"trap #0\n\t" |
:"=g" (res) |
:"0" (SYS_getpriority), "g" (which), "g" (who) |
: "%d0", "%d1", "%d2"); |
if (res >= 0) { |
errno = 0; |
return (int) PZERO - res; |
} |
errno = -res; |
return -1; |
} |
/readdir.c
0,0 → 1,127
#include <dirent.h> |
#include <errno.h> |
#include <sys/syscall.h> |
|
#include "../dirstream.h" |
|
/* |
* readdir fills up the buffer with the readdir system call. it also |
* gives a third parameter (currently ignored, but should be 1) that |
* can with a future kernel be enhanced to be the number of entries |
* to be gotten. |
* |
* Right now the readdir system call return the number of characters |
* in the name - in the future it will probably return the number of |
* entries gotten. No matter - right now we just check for positive: |
* that will always work (as we know that it cannot be bigger than 1 |
* in the future: we just asked for one entry). |
*/ |
static struct dirent * |
old_readdir (DIR *dir) |
{ |
int result; |
int count = NUMENT; |
|
if (dir->dd_size <= dir->dd_nextloc) { |
/* read count of directory entries. For now it should be one. */ |
__asm__ ("movel %2,%/d1\n\t" |
"movel %3,%/d2\n\t" |
"movel %4,%/d3\n\t" |
"movel %1,%/d0\n\t" |
"trap #0\n\t" |
"movel %/d0,%0" |
: "=g" (result) |
: "i" (SYS_readdir), "g" (dir->dd_fd), "g" (dir->dd_buf), |
"g" (count) |
: "%d0", "%d1", "%d2", "%d3" ); |
if (result <= 0) { |
if (result < 0) |
errno = -result; |
return NULL; |
} |
|
/* |
* Right now the readdir system call return the number of |
* characters in the name - in the future it will probably return |
* the number of entries gotten. No matter - right now we just |
* check for positive: |
*/ |
#if 0 |
dir->dd_size = result; |
#else |
dir->dd_size = 1; |
#endif |
|
dir->dd_nextloc = 0; |
} |
|
return &(dir->dd_buf [(dir->dd_nextloc)++]); |
} |
|
#ifdef __ELF__ |
#pragma weak readdir = __libc_readdir |
#endif |
|
struct dirent * |
__libc_readdir (DIR *dir) |
{ |
int result; |
struct dirent *de; |
|
if (!dir) |
{ |
errno = EBADF; |
return NULL; |
} |
|
/* Are we running an old kernel? */ |
if (dir->dd_getdents == no_getdents) |
return old_readdir (dir); |
|
if (dir->dd_size <= dir->dd_nextloc) |
{ |
/* read dir->dd_max bytes of directory entries. */ |
__asm__ ("movel %2,%/d1\n\t" |
"movel %3,%/d2\n\t" |
"movel %4,%/d3\n\t" |
"movel %1,%/d0\n\t" |
"trap #0\n\t" |
"movel %/d0,%0" |
: "=g" (result) |
: "i" (SYS_getdents), "g" (dir->dd_fd), "g" (dir->dd_buf), |
"g" (dir->dd_max) |
: "%d0", "%d1", "%d2", "%d3"); |
|
/* We assume we have getdents (). */ |
dir->dd_getdents = have_getdents; |
if (result <= 0) |
{ |
result = -result; |
if (result > 0) |
{ |
/* Are we right? */ |
if (result == ENOSYS) |
{ |
dir->dd_getdents = no_getdents; |
return old_readdir (dir); |
} |
errno = result; |
} |
|
return NULL; |
} |
|
dir->dd_size = result; |
dir->dd_nextloc = 0; |
} |
|
de = (struct dirent *) ((char *) dir->dd_buf + dir->dd_nextloc); |
|
/* Am I right? H.J. */ |
dir->dd_nextloc += de->d_reclen; |
|
/* We have to save the next offset here. */ |
dir->dd_nextoff = de->d_off; |
|
return de; |
} |
/syscall.c
0,0 → 1,72
/* syscall.c - generalized linux system call interface - rick sladkey */ |
|
#include <stdarg.h> |
#include <syscall.h> |
#include <errno.h> |
|
#ifdef PTHREAD_KERNEL |
|
#pragma weak machdep_syscall = __machdep_syscall |
|
int |
__machdep_syscall (int number, ...) |
{ |
register long res asm ("%d0"); |
register long d1 asm ("%d1"), d2 asm ("%d2"), d3 asm ("%d3"); |
register long d4 asm ("%d4"), d5 asm ("%d5"); |
va_list args; |
|
va_start (args, number); |
d1 = va_arg (args, int); |
d2 = va_arg (args, int); |
d3 = va_arg (args, int); |
d4 = va_arg (args, int); |
d5 = va_arg (args, int); |
va_end (args); |
__asm__ volatile ("trap #0\n\t" |
: "=g" (res) |
: "0" (number), "g" (d1), "g" (d2), "g" (d3), "g" (d4), |
"g" (d5) |
: "%d0"); |
return res; |
} |
|
#else /* PTHREAD_KERNEL */ |
|
/* No weak syscall?. */ |
#undef _POSIX_THREADS |
|
#ifdef _POSIX_THREADS |
#pragma weak syscall |
#endif |
|
int |
syscall(int number, ...) |
{ |
long res; |
register long d0 asm("%d0"); |
register long d1 asm("%d1"), d2 asm("%d2"), d3 asm("%d3"), |
d4 asm("%d4"), d5 asm("%d5"); |
va_list args; |
|
va_start(args, number); |
d1 = va_arg(args, int); |
d2 = va_arg(args, int); |
d3 = va_arg(args, int); |
d4 = va_arg(args, int); |
d5 = va_arg(args, int); |
va_end(args); |
__asm__ volatile ("trap #0\n\t" |
: "=g" (d0) |
: "0" (number), "g" (d1), "g" (d2), "g" (d3), "g" (d4), |
"g" (d5) |
: "%d0"); |
res = d0; |
if (res < 0) { |
errno = -res; |
res = -1; |
} |
return res; |
} |
|
#endif /* PTHREAD_KERNEL */ |
/__brk.c
0,0 → 1,29
#include <unistd.h> |
#include <sys/syscall.h> |
#include <errno.h> |
|
extern void * ___brk_addr; |
|
extern int __init_brk (void); |
|
int __brk(void * end_data_seg) |
{ |
if (__init_brk () == 0) |
{ |
__asm__ volatile ("movel %2,%/d1\n\t" |
"moveq %1,%/d0\n\t" |
"trap #0\n\t" |
"movel %/d0,%0" |
:"=g" (___brk_addr) |
:"i" (SYS_brk),"g" (end_data_seg) : "%d0", "%d1"); |
if (___brk_addr == end_data_seg) |
return 0; |
errno = ENOMEM; |
} |
return -1; |
} |
|
#include <gnu-stabs.h> |
#ifdef weak_alias |
weak_alias (__brk, brk); |
#endif |
/__select.c
0,0 → 1,50
#include <errno.h> |
#include <sys/syscall.h> |
#include <sys/time.h> |
|
#ifdef PTHREAD_KERNEL |
|
#pragma weak machdep_sys_select = __machdep_sys_select |
|
int |
__machdep_sys_select (int nd, fd_set *in, fd_set *out, fd_set *ex, |
struct timeval *tv) |
{ |
register long __res asm ("%d0"); |
__asm__ volatile ("movel %2,%/d1\n\t" |
"trap #0" |
: "=g" (__res) |
: "0" (SYS_select), "g" ((long) &nd) |
: "%d0", "%d1"); |
return (int) __res; |
} |
|
#else /* PTHREAD_KERNEL */ |
|
#ifdef _POSIX_THREADS |
#pragma weak __select |
#endif |
|
int |
__select(int nd, fd_set * in, fd_set * out, fd_set * ex, |
struct timeval * tv) |
{ |
long __res; |
register long d0 asm ("%d0"); |
__asm__ volatile ("movel %2,%/d1\n\t" |
"trap #0\n\t" |
: "=g" (d0) |
: "0" (SYS_select),"g" ((long) &nd) : "%d0", "%d1"); |
__res = d0; |
if (__res >= 0) |
return (int) __res; |
errno = -__res; |
return -1; |
} |
|
#include <gnu-stabs.h> |
#ifdef weak_alias |
weak_alias (__select, select); |
#endif |
|
#endif /* PTHREAD_KERNEL */ |
/ptrace.c
0,0 → 1,32
#include <errno.h> |
#include <sys/ptrace.h> |
#include <sys/syscall.h> |
|
int |
ptrace(int request, int pid, int addr, int data) |
{ |
long ret; |
long res; |
if (request > 0 && request < 4) (long *)data = &ret; |
|
__asm__ volatile ("movel %1,%/d0\n\t" |
"movel %2,%/d1\n\t" |
"movel %3,%/d2\n\t" |
"movel %4,%/d3\n\t" |
"movel %5,%/d4\n\t" |
"trap #0\n\t" |
"movel %/d0,%0" |
:"=g" (res) |
:"i" (SYS_ptrace), "g" (request), "g" (pid), |
"g" (addr), "g" (data) : "%d0", "%d1", "%d2", "%d3", "%d4"); |
|
if (res >= 0) { |
if (request > 0 && request < 4) { |
errno = 0; |
return (ret); |
} |
return (int) res; |
} |
errno = -res; |
return -1; |
} |
/sigsuspend.c
0,0 → 1,51
#include <syscall.h> |
#include <sys/signal.h> |
|
#ifdef PTHREAD_KERNEL |
|
#pragma weak machdep_sys_sigsuspend = __machdep_sys_sigsuspend |
|
int |
__machdep_sys_sigsuspend (const sigset_t *sigmask) |
{ |
int res; |
|
__asm__("movel %1,%/d0\n\t" |
"clrl %/d1\n\t" |
"clrl %/d2\n\t" |
"movel %2,%/d3\n\t" |
"trap #0\n\t" |
"movel %/d0,%0" |
: "=g" (res) |
: "i" (SYS_sigsuspend), "g" (*sigmask) |
: "%d0", "%d1", "%d2", "%d3"); |
return res; |
} |
|
#else /* PTHREAD_KERNEL */ |
|
#ifdef _POSIX_THREADS |
#pragma weak sigsuspend |
#endif |
|
int |
sigsuspend (const sigset_t *sigmask) |
{ |
int res; |
|
__asm__("movel %1,%/d0\n\t" |
"clrl %/d1\n\t" |
"clrl %/d2\n\t" |
"movel %2,%/d3\n\t" |
"trap #0\n\t" |
"movel %/d0,%0" |
:"=g" (res) |
:"i" (SYS_sigsuspend), "g" (*sigmask) |
: "%d0", "%d1", "%d2", "%d3"); |
if (res >= 0) |
return res; |
errno = -res; |
return -1; |
} |
|
#endif /* PTHREAD_KERNEL */ |
/__fpu_control.c
0,0 → 1,51
unsigned long __fpu_control = 0; |
/readdir_r.c
0,0 → 1,126
#include <dirent.h> |
#include <string.h> |
#include <errno.h> |
#include <sys/syscall.h> |
|
#include "../dirstream.h" |
|
/* readdir fills up the buffer with the readdir system call. it also |
gives a third parameter (currently ignored, but should be 1) that |
can with a future kernel be enhanced to be the number of entries to |
be gotten. |
|
Right now the readdir system call return the number of characters |
in the name - in the future it will probably return the number of |
entries gotten. No matter - right now we just check for positive: |
that will always work (as we know that it cannot be bigger than 1 |
in the future: we just asked for one entry). */ |
int |
old_readdir_r (DIR *dir, struct dirent *entry, |
struct dirent **ret) |
{ |
int result; |
int count = NUMENT; |
|
if (dir->dd_size <= dir->dd_nextloc) |
{ |
/* read count of directory entries. For now it should be one. */ |
__asm__ ("movel %2,%/d1\n\t" |
"movel %3,%/d2\n\t" |
"movel %4,%/d3\n\t" |
"movel %1,%/d0\n\t" |
"trap #0\n\t" |
"movel %/d0,%0" |
: "=g" (result) |
: "i" (SYS_readdir), "g" (dir->dd_fd), "g" (dir->dd_buf), |
"g" (count) |
: "%d0", "%d1", "%d2", "%d3" ); |
if (result <= 0) |
{ |
result = -result; |
*ret = NULL; |
return result; |
} |
|
/* Right now the readdir system call return the number of |
characters in the name - in the future it will probably |
return the number of entries gotten. No matter - right now |
we just check for positive: */ |
#if 0 |
dir->dd_size = result; |
#else |
dir->dd_size = 1; |
#endif |
|
dir->dd_nextloc = 0; |
} |
|
/* We copy the dirent entry to entry. */ |
memcpy (entry, &dir->dd_buf[dir->dd_nextloc++], sizeof (struct dirent)); |
*ret = entry; |
return 0; |
} |
|
#ifdef __ELF__ |
#pragma weak readdir_r = __libc_readdir_r |
#endif |
|
int |
__libc_readdir_r (DIR *dir, struct dirent *entry, struct dirent **ret) |
{ |
int result; |
|
if (!dir || !entry || !ret || !*ret) |
return EBADF; |
|
/* Are we running an old kernel? */ |
if (dir->dd_getdents == no_getdents) |
return old_readdir_r (dir, entry, ret); |
|
if (dir->dd_size <= dir->dd_nextloc) |
{ |
/* read dir->dd_max bytes of directory entries. */ |
__asm__ ("movel %2,%/d1\n\t" |
"movel %3,%/d2\n\t" |
"movel %4,%/d3\n\t" |
"movel %1,%/d0\n\t" |
"trap #0\n\t" |
"movel %/d0,%0" |
: "=g" (result) |
: "i" (SYS_getdents), "g" (dir->dd_fd), "g" (dir->dd_buf), |
"g" (dir->dd_max) |
: "%d0", "%d1", "%d2", "%d3"); |
|
/* We assume we have getdents (). */ |
dir->dd_getdents = have_getdents; |
if (result <= 0) |
{ |
result = -result; |
|
if (result == ENOSYS) |
{ |
dir->dd_getdents = no_getdents; |
return old_readdir_r (dir, entry, ret); |
} |
|
*ret = NULL; |
return result; |
} |
|
dir->dd_size = result; |
dir->dd_nextloc = 0; |
} |
|
/* We copy the dirent entry to entry. */ |
memcpy (entry, (char *) dir->dd_buf + dir->dd_nextloc, |
sizeof (struct dirent)); |
*ret = entry; |
|
/* Am I right? H.J. */ |
dir->dd_nextloc += entry->d_reclen; |
|
/* We have to save the next offset here. */ |
dir->dd_nextoff = entry->d_off; |
|
return 0; |
} |
/Makefile
0,0 → 1,59
# |
# Makefile of Linux specific functions for m68k |
# |
|
TOPDIR=../../.. |
|
include $(TOPDIR)/Makeconfig |
include $(TOPDIR)/Makerules |
|
INC_CFLAGS=-I$(TOPDIR) -I. |
|
ifeq ($(MATH),true) |
|
lib all: |
($(MAKE) -C math $@) |
|
else |
|
DIRS:=math crt |
|
ifeq ($(PROFILE),true) |
DIRS:=$(DIRS) gmon |
endif |
|
SRC1S = __brk.c __sbrk.c __select.c __sigact.c getprio.c \ |
ptrace.c readdir.c sigsuspend.c syscall.c libc_exit.c \ |
__setfpucw.c __fpu_control.c __init_brk.c readdir_r.c |
# __load.c __adjtime.c __ntpgttm.c __wait.c __wait3.c __waitpid.c |
# accept.c bind.c msgget.c msgrcv.c msgsnd.c msgctl.c semget.c |
# semop.c semctl.c listen.c mmap.c socket.c socketpair.c tell.c |
# ulimit.c recv.c revcfrom.c send.c sendto.c setpgrp.c setsockopt.c |
# shutdown.c connect.c getpeernam.c getsocknam.c getsockopt.c |
# shmget.c shmat.c shmdt.c shmctl.c |
#SRC2S = __vfork.c vfork.c |
SRC3S = ____sig.S # __adjtimex.S |
|
SRCS= $(SRC1S) $(SRC2S) $(SRC3S) |
ASMS= $(SRC1S:.c=.s) $(SRC2S:.c=.s) $(SRC3S:.S=.s) |
OBJS= $(SRC1S:.c=.o) $(SRC3S:.S=.o) |
ALIASES= $(SRC2S:.c=.o) |
|
include $(TOPDIR)/Maketargets |
|
ifeq ($(STATIC),true) |
|
#LIBIEEE=$(STATIC_DIR)/libieee.a |
|
#lib:: $(LIBIEEE) |
|
$(STATIC_DIR)/$(SUBDIR)/ieee.o: ieee.c |
$(CC) $(CFLAGS) -c $< -o $@ |
|
$(LIBIEEE): $(STATIC_DIR)/$(SUBDIR)/ieee.o |
$(RM) -f $(LIBIEEE) |
$(AR) $(AR_FLAGS) $(LIBIEEE) $? |
$(REALRANLIB) $(LIBIEEE) |
endif |
|
endif |