2009-12-16 Ralf Corsépius <ralf.corsepius@rtems.org>

* libc/sys/rtems/machine/_types.h: New (Derived from
        machine/_default_types.h).
        * libc/sys/rtems/crt0.c: Rework. Introduce macro RTEMS_STUB.
        * libc/sys/rtems/sys/param.h:
        Update copyright notice from FreeBSD.
        Remove HZ.
        Add #include <sys/priority.h>
        Remove priority handling (moved to sys/priority.h).
        Remove CLBYTES (Unused, abandoned in BSD).
        * libc/sys/rtems/sys/queue.h: Update copyright (from FreeBSD).
        Remove CIRCLEQ_*.
This commit is contained in:
Jeff Johnston 2009-12-16 18:28:15 +00:00
parent beeae48288
commit 32a08d0e75
4 changed files with 105 additions and 161 deletions

View File

@ -1,3 +1,17 @@
2009-12-16 Ralf Corsépius <ralf.corsepius@rtems.org>
* libc/sys/rtems/machine/_types.h: New (Derived from
machine/_default_types.h).
* libc/sys/rtems/crt0.c: Rework. Introduce macro RTEMS_STUB.
* libc/sys/rtems/sys/param.h:
Update copyright notice from FreeBSD.
Remove HZ.
Add #include <sys/priority.h>
Remove priority handling (moved to sys/priority.h).
Remove CLBYTES (Unused, abandoned in BSD).
* libc/sys/rtems/sys/queue.h: Update copyright (from FreeBSD).
Remove CIRCLEQ_*.
2009-12-15 Conny Marco Menebrocker <c-m-m@gmx.de>
* libc/machine/xc16x/Makefile.am: Fix typo and refer

View File

@ -12,15 +12,20 @@
#include <reent.h>
#include <signal.h> // sigset_t
#include <time.h> // struct timespec
void rtems_provides_crt0( void ) {} /* dummy symbol so file always has one */
/* RTEMS provides some of its own routines including a Malloc family */
#define RTEMS_STUB(ret, func) \
ret rtems_stub_##func {}; \
ret func
void *malloc() { return 0; }
void *realloc() { return 0; }
void free() { ; }
void abort() { ; }
int raise() { return -1; }
/* RTEMS provides some of its own routines including a Malloc family */
RTEMS_STUB(void *,malloc(size_t s)) { return 0; }
RTEMS_STUB(void *,realloc(void* p, size_t s)) { return 0; }
RTEMS_STUB(void, free(void)) { ; }
RTEMS_STUB(_PTR, calloc(struct _reent *r, size_t s1, size_t s2)) {}
#if defined(__GNUC__)
/*
@ -43,54 +48,91 @@ int rtems_gxx_recursive_mutex_trylock() { return -1; }
int rtems_gxx_recursive_mutex_unlock() { return -1; }
#endif
/* stubs for functions RTEMS provides */
RTEMS_STUB(int, close (int fd)) { return -1; }
RTEMS_STUB(int, dup2(int oldfd, int newfd)) { return -1; }
RTEMS_STUB(int, fcntl( int fd, int cmd, ... /* arg */ )) { return -1; }
RTEMS_STUB(pid_t, fork(void)) { return -1; }
RTEMS_STUB(int, fstat(int fd, struct stat *buf)) { return -1; }
RTEMS_STUB(int, getdents(int fd, void *dp, int count)) { return -1; }
RTEMS_STUB(char *, getlogin(void)) { return 0; }
RTEMS_STUB(struct passwd *, getpwnam(const char *name)) { return 0; }
RTEMS_STUB(struct passwd *, getpwuid(uid_t uid)) { return 0; }
RTEMS_STUB(uid_t, getuid(void)) { return 0; }
RTEMS_STUB(int, nanosleep(const struct timespec *req, struct timespec *rem)) { return -1; }
RTEMS_STUB(_off_t, lseek(int fd, _off_t offset, int whence)) { return -1; }
RTEMS_STUB(int, lstat(const char *path, struct stat *buf)) { return -1; }
RTEMS_STUB(int, open(const char *pathname, int flags, int mode)) { return -1; }
RTEMS_STUB(int, pipe(int pipefd[2])) { return -1; }
RTEMS_STUB(_ssize_t, read(int fd, void *buf, size_t count)) { return -1; }
RTEMS_STUB(int, sigfillset(sigset_t *set)) { return -1; }
RTEMS_STUB(int, sigprocmask(int how, const sigset_t *set, sigset_t *oldset)) { return -1; }
RTEMS_STUB(int, stat(const char *path, struct stat *buf)) { return -1; }
RTEMS_STUB(int, unlink(const char *pathname)) { return -1; }
RTEMS_STUB(pid_t, vfork(void)) { return -1; }
#if !defined(_NO_POPEN) && !defined(_NO_WORDEXP)
/* pulled in by libc/sys/posix/popen.c and libc/sys/posix/word*.c */
RTEMS_STUB(int, waitpid (pid_t pid, int *status, int options)) { return -1; }
#endif
RTEMS_STUB(_ssize_t, write (int fd, const void *buf, size_t nbytes)) { return -1; }
/* stubs for functions from reent.h */
int _close_r (struct _reent *r, int fd) { return -1; }
#if NOT_USED_BY_RTEMS
int _execve_r (struct _reent *r, char *, char **, char **) { return -1; }
RTEMS_STUB(int, _close_r (struct _reent *r, int fd)) { return -1; }
#if defined(_NO_EXECVE)
RTEMS_STUB(int, _execve_r (struct _reent *r, char *, char **, char **)) { return -1; }
#endif
int _fcntl_r ( struct _reent *ptr, int fd, int cmd, int arg ) { return -1;}
#if NOT_USED_BY_RTEMS
int _fork_r (struct _reent *r) { return -1; }
RTEMS_STUB(int, _fcntl_r (struct _reent *ptr, int fd, int cmd, int arg )) { return -1; }
#if !(defined (REENTRANT_SYSCALLS_PROVIDED) || defined (NO_EXEC))
#ifndef NO_FORK
/* cf. newlib/libc/reent/execr.c */
RTEMS_STUB(int, _fork_r (struct _reent *r)) { return -1; }
#endif
int _fstat_r (struct _reent *r, int fd, struct stat *buf) { return -1; }
int _getpid_r (struct _reent *r) { return -1; }
int _kill_r ( struct _reent *r, int pid, int sig ) { return -1; }
int _link_r ( struct _reent *ptr, const char *existing, const char *new) { return -1; }
_off_t _lseek_r ( struct _reent *ptr, int fd, _off_t offset, int whence ) { return -1; }
int _open_r (struct _reent *r, const char *buf, int flags, int mode) { return -1; }
_ssize_t _read_r (struct _reent *r, int fd, void *buf, size_t nbytes) { return -1; }
#if NOT_USED_BY_RTEMS
void *_sbrk_r (struct _reent *r, ptrdiff_t) { return -1; }
#endif
int _stat_r (struct _reent *r, const char *path, struct stat *buf) { return -1; }
_CLOCK_T_ _times_r (struct _reent *r, struct tms *ptms) { return -1; }
int _unlink_r (struct _reent *r, const char *path) { return -1; }
#if NOT_USED_BY_RTEMS
int _wait_r (struct _reent *r, int *) { return -1; }
RTEMS_STUB(int, _fstat_r (struct _reent *r, int fd, struct stat *buf)) { return -1; }
RTEMS_STUB(int, _getpid_r (struct _reent *r)) { return -1; }
RTEMS_STUB(int, _gettimeofday_r(struct _reent *r, struct timeval *tp, void *tzp)) { return 0; }
RTEMS_STUB(int, _isatty_r (struct _reent *r, int fd)) { return isatty( fd ); }
RTEMS_STUB(int, _kill_r (struct _reent *r, int pid, int sig )) { return -1; }
#if !defined(REENTRANT_SYSCALLS_PROVIDED)
/* cf. newlib/libc/reent/linkr.c */
RTEMS_STUB(int, _link_r (struct _reent *, const char *, const char *)) { return -1; }
#endif
_ssize_t _write_r (struct _reent *r, int fd, const void *buf, size_t nbytes) { return -1; }
RTEMS_STUB(_off_t, _lseek_r ( struct _reent *ptr, int fd, _off_t offset, int whence )) { return -1; }
RTEMS_STUB(int, _open_r (struct _reent *r, const char *buf, int flags, int mode)) { return -1; }
RTEMS_STUB(_ssize_t, _read_r (struct _reent *r, int fd, void *buf, size_t nbytes)) { return -1; }
RTEMS_STUB(int, _rename_r (struct _reent *r, const char *a, const char *b)){ return -1; }
#if !(defined (REENTRANT_SYSCALLS_PROVIDED) || defined (MALLOC_PROVIDED))
/* cf. newlib/libc/reent/sbrkr.c */
RTEMS_STUB(void *,_sbrk_r (struct _reent *r, ptrdiff_t)) { return -1; }
#endif
RTEMS_STUB(int, _stat_r (struct _reent *r, const char *path, struct stat *buf)) { return -1; }
RTEMS_STUB(_CLOCK_T_, _times_r (struct _reent *r, struct tms *ptms)) { return -1; }
RTEMS_STUB(int, _unlink_r (struct _reent *r, const char *path)) { return -1; }
#if !(defined (REENTRANT_SYSCALLS_PROVIDED) || defined (NO_EXEC))
/* cf. newlib/libc/reent/execr.c */
RTEMS_STUB(int, _wait_r (struct _reent *r, int *)) { return -1; }
#endif
RTEMS_STUB(_ssize_t, _write_r (struct _reent *r, int fd, const void *buf, size_t nbytes)) { return -1; }
int isatty( int fd ) { return -1; }
_realloc_r() {}
_calloc_r() {}
_malloc_r() {}
_free_r() {}
RTEMS_STUB(int, _execve(const char *path, char * const *argv, char * const *envp)) { return -1; }
RTEMS_STUB(void, _exit(int status)) { while(1); }
/* stubs for functions required by libc/posix */
int getdents(int fd, void *dp, int count) { return -1; }
struct timespec;
int nanosleep(const struct timespec *req, struct timespec *rem) { return -1; }
int _execve(const char *path, char * const *argv, char * const *envp) { return -1; }
int _exit(int status) { return -1; }
/* Pulled in by newlib/libc/posix/glob.c */
#ifndef _NO_GLOB
#ifndef __NETBSD_SYSCALLS
RTEMS_STUB(int, issetugid (void)) { return 0; }
#endif
#endif
/* gcc can implicitly generate references to these */
/* strcmp() {} */
/* strcpy() {} */
/* strlen() {} */
/* memcmp() {} */
/* memcpy() {} */
/* memset() {} */
/* stdlib.h */
RTEMS_STUB(_PTR, _realloc_r(struct _reent *r, _PTR p, size_t s)) {}
RTEMS_STUB(_PTR, _calloc_r(struct _reent *r, size_t s1, size_t s2)) {}
RTEMS_STUB(_PTR, _malloc_r(struct _reent *r, size_t s)) {}
RTEMS_STUB(_VOID, _free_r(struct _reent *r, _PTR p)) {}
/* stubs for functions required by libc/stdlib */
RTEMS_STUB(void, __assert_func(const char *file, int line, const char *failedexpr)) {}
/* The PowerPC expects certain symbols to be defined in the linker script. */

View File

@ -15,10 +15,6 @@
* 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.
@ -47,7 +43,6 @@
#include <sys/config.h>
#include <machine/endian.h>
# define HZ (60)
# define PATHSIZE (1024)
/* end of from newlib's <sys/param.h> */
@ -86,13 +81,13 @@
#define MAXHOSTNAMELEN 256 /* max hostname size */
/* More types and definitions used throughout the kernel. */
#ifdef KERNEL
#if defined(KERNEL) || defined(_KERNEL)
#include <sys/cdefs.h>
#include <sys/errno.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/ucred.h>
#include <sys/uio.h>
#include <sys/priority.h>
#ifndef FALSE
#define FALSE 0
@ -109,23 +104,6 @@
#include <machine/param.h>
#include <machine/limits.h>
/*
* Priorities. Note that with 32 run queues, differences less than 4 are
* insignificant.
*/
#define PSWP 0
#define PVM 4
#define PINOD 8
#define PRIBIO 16
#define PVFS 20
#define PZERO 22 /* No longer magic, shouldn't be here. XXX */
#define PSOCK 24
#define PWAIT 32
#define PLOCK 36
#define PPAUSE 40
#define PUSER 50
#define MAXPRI 127 /* Priorities range from 0 through MAXPRI. */
#define PRIMASK 0x0ff
#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */
@ -136,15 +114,6 @@
#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */
#define NODEV (dev_t)(-1) /* non-existent device */
/*
* Clustering of hardware pages on machines with ridiculously small
* page sizes is done here. The paging subsystem deals with units of
* CLSIZE pte's describing PAGE_SIZE (from machine/machparam.h) pages each.
*/
#if 0
#define CLBYTES (CLSIZE*PAGE_SIZE)
#endif
#define CBLOCK 128 /* Clist block size, must be a power of 2. */
#define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */
/* Data chars/clist. */
@ -200,7 +169,7 @@
#define powerof2(x) ((((x)-1)&(x))==0)
/* Macros for min/max. */
#ifndef KERNEL
#if !(defined(KERNEL) || defined(_KERNEL))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#endif

View File

@ -10,10 +10,6 @@
* 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.
@ -480,84 +476,7 @@ struct { \
QMD_TRACE_ELEM(&(elm)->field); \
} while (0)
/*
* Circular queue definitions.
*/
#define CIRCLEQ_HEAD(name, type) \
struct name { \
struct type *cqh_first; /* first element */ \
struct type *cqh_last; /* last element */ \
}
#define CIRCLEQ_ENTRY(type) \
struct { \
struct type *cqe_next; /* next element */ \
struct type *cqe_prev; /* previous element */ \
}
/*
* Circular queue functions.
*/
#define CIRCLEQ_INIT(head) { \
(head)->cqh_first = (void *)(head); \
(head)->cqh_last = (void *)(head); \
}
#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) { \
(elm)->field.cqe_next = (listelm)->field.cqe_next; \
(elm)->field.cqe_prev = (listelm); \
if ((listelm)->field.cqe_next == (void *)(head)) \
(head)->cqh_last = (elm); \
else \
(listelm)->field.cqe_next->field.cqe_prev = (elm); \
(listelm)->field.cqe_next = (elm); \
}
#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) { \
(elm)->field.cqe_next = (listelm); \
(elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
if ((listelm)->field.cqe_prev == (void *)(head)) \
(head)->cqh_first = (elm); \
else \
(listelm)->field.cqe_prev->field.cqe_next = (elm); \
(listelm)->field.cqe_prev = (elm); \
}
#define CIRCLEQ_INSERT_HEAD(head, elm, field) { \
(elm)->field.cqe_next = (head)->cqh_first; \
(elm)->field.cqe_prev = (void *)(head); \
if ((head)->cqh_last == (void *)(head)) \
(head)->cqh_last = (elm); \
else \
(head)->cqh_first->field.cqe_prev = (elm); \
(head)->cqh_first = (elm); \
}
#define CIRCLEQ_INSERT_TAIL(head, elm, field) { \
(elm)->field.cqe_next = (void *)(head); \
(elm)->field.cqe_prev = (head)->cqh_last; \
if ((head)->cqh_first == (void *)(head)) \
(head)->cqh_first = (elm); \
else \
(head)->cqh_last->field.cqe_next = (elm); \
(head)->cqh_last = (elm); \
}
#define CIRCLEQ_REMOVE(head, elm, field) { \
if ((elm)->field.cqe_next == (void *)(head)) \
(head)->cqh_last = (elm)->field.cqe_prev; \
else \
(elm)->field.cqe_next->field.cqe_prev = \
(elm)->field.cqe_prev; \
if ((elm)->field.cqe_prev == (void *)(head)) \
(head)->cqh_first = (elm)->field.cqe_next; \
else \
(elm)->field.cqe_prev->field.cqe_next = \
(elm)->field.cqe_next; \
}
#ifdef KERNEL
#if defined(KERNEL) || defined(_KERNEL)
/*
* XXX insque() and remque() are an old way of handling certain queues.