This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Remove warnings from RTEMS crt0.c


On 08/03/2011 07:38 AM, Ralf Corsepius wrote:
On 08/02/2011 08:13 PM, Joel Sherrill wrote:
Hi,

The RTEMS crt0.c is just a stub so autoconf
will find methods. It uses a macro to
generate stub bodies for routines we want
autoconf to find that are not in libc.
The macro that generates the stubs does
not generate a return statement with properly
typed argument. So when you do a -Wall, you
get lots of warnings. This just eliminates
the warnings.

OK to commit?

Not for now. I'd firstly want to reproduce the warnings you are mentioning and check why I don't see them.

However, I am currently on vacation and only sporadically touch a
keyboard. I'll try to check ASAP, but I hardly will be able to check
before last week of August.

I intend to apply the patch below.


Ralf
2011-08-19  Ralf Corsépius <ralf.corsepius@rtems.org>
 
	* libc/sys/rtems/crt0.c: Rework RTEMS_STUB macro.
	Include <unistd.h>.
	Remove C++-style comments.
	Remove hppa, a29k.

Index: libc/sys/rtems/crt0.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/rtems/crt0.c,v
retrieving revision 1.12
diff -u -r1.12 crt0.c
--- libc/sys/rtems/crt0.c	7 Jan 2011 19:27:33 -0000	1.12
+++ libc/sys/rtems/crt0.c	19 Aug 2011 17:16:43 -0000
@@ -12,20 +12,21 @@
 
 #include <reent.h>
 
-#include <signal.h> // sigset_t
-#include <time.h> // struct timespec
+#include <signal.h> /* sigset_t */
+#include <time.h> /* struct timespec */
+#include <unistd.h> /* isatty */
 
 void rtems_provides_crt0( void ) {}  /* dummy symbol so file always has one */
 
-#define RTEMS_STUB(ret, func) \
-ret rtems_stub_##func {}; \
-ret func
+#define RTEMS_STUB(ret, func, body) \
+ret rtems_stub_##func body; \
+ret func body
 
 /* 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* ptr)) { ; }
-RTEMS_STUB(_PTR, calloc(size_t s1, size_t s2)) {}
+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* ptr), { })
+RTEMS_STUB(_PTR, calloc(size_t s1, size_t s2), { return 0; })
 
 #if defined(__GNUC__)
 /*
@@ -49,90 +50,93 @@
 #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; }
+RTEMS_STUB(int, clock_gettime(clockid_t clk_id, struct timespec *tp), { return -1; })
+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(int, gettimeofday(struct timeval *tv, struct timezone *tz), { return -1; })
+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, sched_yield(void), { 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; }
+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; }
+RTEMS_STUB(_ssize_t, write (int fd, const void *buf, size_t nbytes), { return -1; })
 
 /* stubs for functions from reent.h */
-RTEMS_STUB(int, _close_r (struct _reent *r, int fd)) { 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; }
+RTEMS_STUB(int, _execve_r (struct _reent *r, char *, char **, char **), { return -1; })
 #endif
-RTEMS_STUB(int, _fcntl_r (struct _reent *ptr, int fd, int cmd, int arg )) { 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; }
+RTEMS_STUB(int, _fork_r (struct _reent *r), { return -1; })
 #endif
 #endif
-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; }
+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; }
+RTEMS_STUB(int, _link_r (struct _reent *r, const char *oldpath, const char *newpath), { return -1; })
 #endif
-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; }
+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; }
+RTEMS_STUB(void *,_sbrk_r (struct _reent *r, ptrdiff_t addr), { return 0; })
 #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; }
+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; }
+RTEMS_STUB(int, _wait_r (struct _reent *r, int *status), { return -1; })
 #endif
-RTEMS_STUB(_ssize_t, _write_r (struct _reent *r, int fd, const void *buf, size_t nbytes)) { return -1; }
+RTEMS_STUB(_ssize_t, _write_r (struct _reent *r, int fd, const void *buf, size_t nbytes), { return -1; })
 
 
-RTEMS_STUB(int, _execve(const char *path, char * const *argv, char * const *envp)) { return -1; }
-RTEMS_STUB(void, _exit(int status)) { while(1); }
+RTEMS_STUB(int, _execve(const char *path, char * const *argv, char * const *envp), { return -1; })
+RTEMS_STUB(void, _exit(int status), { while(1); })
 
 /* Pulled in by newlib/libc/posix/glob.c */
 #ifndef _NO_GLOB
 #ifndef __NETBSD_SYSCALLS
-RTEMS_STUB(int, issetugid (void)) { return 0; }
+RTEMS_STUB(int, issetugid (void), { return 0; })
 #endif
 #endif
 
 /* 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)) {}
+RTEMS_STUB(_PTR, _realloc_r(struct _reent *r, _PTR p, size_t s), { return 0; })
+RTEMS_STUB(_PTR, _calloc_r(struct _reent *r, size_t s1, size_t s2), { return 0; })
+RTEMS_STUB(_PTR, _malloc_r(struct _reent * r, size_t s), { return 0; })
+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)) {}
+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. */
 
@@ -154,41 +158,6 @@
 int __EH_FRAME_BEGIN__;
 #endif
 
-/*  The hppa expects this to be defined in the real crt0.s. 
- *  Also for some reason, the hppa1.1 does not find atexit()
- *  during the AC_PROG_CC tests.
- */
-
-#if defined(__hppa__)
-/*
-  asm ( ".subspa \$GLOBAL\$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=40");
-  asm ( ".export \$global\$" );
-  asm ( "\$global\$:");
-*/
-
-  asm (".text");
-  asm (".global");
-  asm (".EXPORT $$dyncall,ENTRY");
-  asm ("$$dyncall:");
-  int atexit(void (*function)(void)) { return 0; }
-#endif
-
-
-/*
- *  The AMD a29k generates code expecting the following.
- */
-
-#if defined(_AM29000) || defined(_AM29K)
-asm (".global V_SPILL, V_FILL" );
-asm (".global V_EPI_OS, V_BSD_OS" );
-
-asm (".equ    V_SPILL, 64" );
-asm (".equ    V_FILL, 65" );
-
-asm (".equ    V_BSD_OS, 66" );
-asm (".equ    V_EPI_OS, 69" );
-#endif
-
 #if defined(__AVR__)
 /*
  * Initial stack pointer address "__stack"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]