Home | History | Annotate | Line # | Download | only in compat
compat_defs.h revision 1.1
      1  1.1  thorpej /*	$NetBSD: compat_defs.h,v 1.1 2002/01/22 20:42:59 thorpej Exp $	*/
      2  1.1  thorpej 
      3  1.1  thorpej #ifndef	__NETBSD_COMPAT_DEFS_H__
      4  1.1  thorpej #define	__NETBSD_COMPAT_DEFS_H__
      5  1.1  thorpej 
      6  1.1  thorpej /* System headers needed for (re)definitions below. */
      7  1.1  thorpej 
      8  1.1  thorpej #include <sys/types.h>
      9  1.1  thorpej #include <errno.h>
     10  1.1  thorpej #include <fcntl.h>
     11  1.1  thorpej #include <limits.h>
     12  1.1  thorpej #include <paths.h>
     13  1.1  thorpej #include <stdio.h>
     14  1.1  thorpej #include <string.h>
     15  1.1  thorpej 
     16  1.1  thorpej #if HAVE_INTTYPES_H
     17  1.1  thorpej #include <inttypes.h>
     18  1.1  thorpej #endif
     19  1.1  thorpej #if HAVE_STDDEF_H
     20  1.1  thorpej #include <stddef.h>
     21  1.1  thorpej #endif
     22  1.1  thorpej #if !HAVE_VIS_H
     23  1.1  thorpej #include "compat_vis.h"
     24  1.1  thorpej #endif
     25  1.1  thorpej 
     26  1.1  thorpej #if !defined(__attribute__) && !defined(__GNUC__)
     27  1.1  thorpej #define __attribute__(x)
     28  1.1  thorpej #endif
     29  1.1  thorpej 
     30  1.1  thorpej /* Type substitutes. */
     31  1.1  thorpej 
     32  1.1  thorpej #if !HAVE_ID_T
     33  1.1  thorpej typedef unsigned long id_t;
     34  1.1  thorpej #endif
     35  1.1  thorpej 
     36  1.1  thorpej /* Prototypes for replacement functions. */
     37  1.1  thorpej 
     38  1.1  thorpej #if !HAVE_BASENAME
     39  1.1  thorpej char *basename(char *);
     40  1.1  thorpej #endif
     41  1.1  thorpej 
     42  1.1  thorpej #if !HAVE_DIRNAME
     43  1.1  thorpej char *dirname(char *);
     44  1.1  thorpej #endif
     45  1.1  thorpej 
     46  1.1  thorpej #if !HAVE_ERR_H
     47  1.1  thorpej void err(int, const char *, ...) __attribute__((noreturn));
     48  1.1  thorpej void errx(int, const char *, ...) __attribute__((noreturn));
     49  1.1  thorpej void warn(const char *, ...);
     50  1.1  thorpej void warnx(const char *, ...);
     51  1.1  thorpej #endif
     52  1.1  thorpej 
     53  1.1  thorpej #if !HAVE_FGETLN
     54  1.1  thorpej char *fgetln(FILE *, size_t *);
     55  1.1  thorpej #endif
     56  1.1  thorpej 
     57  1.1  thorpej #if !HAVE_FLOCK
     58  1.1  thorpej # define LOCK_SH		0x01
     59  1.1  thorpej # define LOCK_EX		0x02
     60  1.1  thorpej # define LOCK_NB		0x04
     61  1.1  thorpej # define LOCK_UN		0x08
     62  1.1  thorpej int flock(int, int);
     63  1.1  thorpej #endif
     64  1.1  thorpej 
     65  1.1  thorpej #if !HAVE_FPARSELN
     66  1.1  thorpej # define FPARSELN_UNESCESC	0x01
     67  1.1  thorpej # define FPARSELN_UNESCCONT	0x02
     68  1.1  thorpej # define FPARSELN_UNESCCOMM	0x04
     69  1.1  thorpej # define FPARSELN_UNESCREST	0x08
     70  1.1  thorpej # define FPARSELN_UNESCALL	0x0f
     71  1.1  thorpej char *fparseln(FILE *, size_t *, size_t *, const char [3], int);
     72  1.1  thorpej #endif
     73  1.1  thorpej 
     74  1.1  thorpej #if !HAVE_SETPROGNAME
     75  1.1  thorpej const char *getprogname(void);
     76  1.1  thorpej void setprogname(const char *);
     77  1.1  thorpej #endif
     78  1.1  thorpej 
     79  1.1  thorpej #if !HAVE_STRLCAT
     80  1.1  thorpej size_t strlcat(char *, const char *, size_t);
     81  1.1  thorpej #endif
     82  1.1  thorpej 
     83  1.1  thorpej #if !HAVE_STRLCPY
     84  1.1  thorpej size_t strlcpy(char *, const char *, size_t);
     85  1.1  thorpej #endif
     86  1.1  thorpej 
     87  1.1  thorpej #if !HAVE_PREAD
     88  1.1  thorpej ssize_t pread(int, void *, size_t, off_t);
     89  1.1  thorpej #endif
     90  1.1  thorpej 
     91  1.1  thorpej #if !HAVE_PWRITE
     92  1.1  thorpej ssize_t pwrite(int, const void *, size_t, off_t);
     93  1.1  thorpej #endif
     94  1.1  thorpej 
     95  1.1  thorpej /*
     96  1.1  thorpej  * getmode() and setmode() are always defined, as these function names
     97  1.1  thorpej  * exist but with very different meanings on other OS's.  The compat
     98  1.1  thorpej  * versions here simply accept an octal mode number; the "u+x,g-w" type
     99  1.1  thorpej  * of syntax is not accepted.
    100  1.1  thorpej  */
    101  1.1  thorpej 
    102  1.1  thorpej #define getmode __nbcompat_getmode
    103  1.1  thorpej #define setmode __nbcompat_setmode
    104  1.1  thorpej 
    105  1.1  thorpej mode_t getmode(const void *, mode_t);
    106  1.1  thorpej void *setmode(const char *);
    107  1.1  thorpej 
    108  1.1  thorpej /* Eliminate RCS Id strings, assertions embedded in binaries. */
    109  1.1  thorpej 
    110  1.1  thorpej #undef _DIAGASSERT
    111  1.1  thorpej #define _DIAGASSERT(x) /**/
    112  1.1  thorpej #define lint
    113  1.1  thorpej 
    114  1.1  thorpej /* Assume an ANSI compiler for the host. */
    115  1.1  thorpej 
    116  1.1  thorpej #undef __P
    117  1.1  thorpej #define __P(x) x
    118  1.1  thorpej 
    119  1.1  thorpej #undef BIG_ENDIAN
    120  1.1  thorpej #undef LITTLE_ENDIAN
    121  1.1  thorpej #define BIG_ENDIAN 4321
    122  1.1  thorpej #define LITTLE_ENDIAN 1234
    123  1.1  thorpej 
    124  1.1  thorpej #undef BYTE_ORDER
    125  1.1  thorpej #if WORDS_BIGENDIAN
    126  1.1  thorpej #define BYTE_ORDER BIG_ENDIAN
    127  1.1  thorpej #else
    128  1.1  thorpej #define BYTE_ORDER LITTLE_ENDIAN
    129  1.1  thorpej #endif
    130  1.1  thorpej 
    131  1.1  thorpej #undef MIN
    132  1.1  thorpej #undef MAX
    133  1.1  thorpej #define MIN(a,b) ((a) < (b) ? (a) : (b))
    134  1.1  thorpej #define MAX(a,b) ((a) > (b) ? (a) : (b))
    135  1.1  thorpej 
    136  1.1  thorpej /* Some definitions not available on all systems. */
    137  1.1  thorpej 
    138  1.1  thorpej #ifndef _PATH_DEFPATH
    139  1.1  thorpej #define _PATH_DEFPATH "/usr/bin:/bin:/usr/local/bin"
    140  1.1  thorpej #endif
    141  1.1  thorpej #ifndef _PATH_DEV
    142  1.1  thorpej #define _PATH_DEV "/dev/"
    143  1.1  thorpej #endif
    144  1.1  thorpej #ifndef _PATH_DEVNULL
    145  1.1  thorpej #define _PATH_DEVNULL _PATH_DEV "null"
    146  1.1  thorpej #endif
    147  1.1  thorpej #ifndef _PATH_TMP
    148  1.1  thorpej #define _PATH_TMP "/tmp/"
    149  1.1  thorpej #endif
    150  1.1  thorpej 
    151  1.1  thorpej #ifndef EFTYPE
    152  1.1  thorpej #define EFTYPE EIO
    153  1.1  thorpej #endif
    154  1.1  thorpej 
    155  1.1  thorpej #ifndef MAXBSIZE
    156  1.1  thorpej #define MAXBSIZE (64 * 1024)
    157  1.1  thorpej #endif
    158  1.1  thorpej 
    159  1.1  thorpej #ifndef O_EXLOCK
    160  1.1  thorpej #define O_EXLOCK 0
    161  1.1  thorpej #endif
    162  1.1  thorpej #ifndef O_SHLOCK
    163  1.1  thorpej #define O_SHLOCK 0
    164  1.1  thorpej #endif
    165  1.1  thorpej 
    166  1.1  thorpej #endif	/* !__NETBSD_COMPAT_DEFS_H__ */
    167