Changeset b5aca58 in rtems-libbsd


Ignore:
Timestamp:
Jun 16, 2015, 3:16:37 AM (4 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.11, 5283630d2c9d40deb0183696d278e02644fe4326, freebsd-9.3, bc2ba9a9cdc7381c2a4f2ae6ee303be636f31368
Children:
50500b5
Parents:
59a9e6a
Message:

Add error() to the BSD program support.

Location:
rtemsbsd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • rtemsbsd/include/machine/rtems-bsd-program.h

    r59a9e6a rb5aca58  
    5757rtems_bsd_program_exit(int exit_code) __dead2;
    5858
     59void
     60rtems_bsd_program_error(const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
     61
    5962const char *
    6063rtems_bsd_program_get_name(void);
     
    7073
    7174#ifndef RTEMS_BSD_PROGRAM_NO_EXIT_WRAP
     75  #undef exit
    7276  #define exit(code) rtems_bsd_program_exit(code)
    7377#endif
    7478
     79#ifndef RTEMS_BSD_PROGRAM_NO_ERROR_WRAP
     80  #undef error
     81  #define error(fmt, ...) rtems_bsd_program_error(fmt, ## __VA_ARGS__)
     82#endif
     83
    7584#ifndef RTEMS_BSD_PROGRAM_NO_GETPROGNAME_WRAP
     85  #undef getprogname
    7686  #define getprogname() rtems_bsd_program_get_name()
    7787#endif
    7888
    7989#ifndef RTEMS_BSD_PROGRAM_NO_PRINTF_WRAP
     90  #undef printf
    8091  #define printf(...) fprintf(stdout, __VA_ARGS__)
    8192#endif
  • rtemsbsd/rtems/rtems-bsd-program.c

    r59a9e6a rb5aca58  
    5353#include <stdlib.h>
    5454
     55#include <machine/rtems-bsd-program.h>
     56
    5557struct rtems_bsd_program_control {
    5658        void *context;
     
    117119}
    118120
     121void
     122rtems_bsd_program_error(const char *fmt, ...)
     123{
     124  va_list list;
     125  va_start(list, fmt);
     126  vfprintf(stderr, fmt, list);
     127  fprintf(stderr, "\n");
     128  va_end(list);
     129  rtems_bsd_program_exit(1);
     130}
     131
    119132const char *
    120133rtems_bsd_program_get_name(void)
Note: See TracChangeset for help on using the changeset viewer.