138451Smsmith/*
238451Smsmith * Copyright (c) 1998 Michael Smith.
338451Smsmith * All rights reserved.
438451Smsmith *
538451Smsmith * Redistribution and use in source and binary forms, with or without
638451Smsmith * modification, are permitted provided that the following conditions
738451Smsmith * are met:
838451Smsmith * 1. Redistributions of source code must retain the above copyright
938451Smsmith *    notice, this list of conditions and the following disclaimer.
1038451Smsmith * 2. Redistributions in binary form must reproduce the above copyright
1138451Smsmith *    notice, this list of conditions and the following disclaimer in the
1238451Smsmith *    documentation and/or other materials provided with the distribution.
1338451Smsmith *
1438451Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1538451Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1638451Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1738451Smsmith * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1838451Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1938451Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2038451Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2138451Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2238451Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2338451Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2438451Smsmith * SUCH DAMAGE.
2538451Smsmith *
2650476Speter * $FreeBSD: stable/11/stand/libsa/stand.h 346477 2019-04-21 03:43:27Z kevans $
2738451Smsmith * From	$NetBSD: stand.h,v 1.22 1997/06/26 19:17:40 drochner Exp $
2838451Smsmith */
2938451Smsmith
3038451Smsmith/*-
3138451Smsmith * Copyright (c) 1993
3238451Smsmith *	The Regents of the University of California.  All rights reserved.
3338451Smsmith *
3438451Smsmith * Redistribution and use in source and binary forms, with or without
3538451Smsmith * modification, are permitted provided that the following conditions
3638451Smsmith * are met:
3738451Smsmith * 1. Redistributions of source code must retain the above copyright
3838451Smsmith *    notice, this list of conditions and the following disclaimer.
3938451Smsmith * 2. Redistributions in binary form must reproduce the above copyright
4038451Smsmith *    notice, this list of conditions and the following disclaimer in the
4138451Smsmith *    documentation and/or other materials provided with the distribution.
4238451Smsmith * 4. Neither the name of the University nor the names of its contributors
4338451Smsmith *    may be used to endorse or promote products derived from this software
4438451Smsmith *    without specific prior written permission.
4538451Smsmith *
4638451Smsmith * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
4738451Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4838451Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4938451Smsmith * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
5038451Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5138451Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5238451Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5338451Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5438451Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5538451Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5638451Smsmith * SUCH DAMAGE.
5738451Smsmith *
5838451Smsmith *	@(#)stand.h	8.1 (Berkeley) 6/11/93
5938451Smsmith */
6038451Smsmith
61146327Sobrien#ifndef	STAND_H
62146327Sobrien#define	STAND_H
63146327Sobrien
6438451Smsmith#include <sys/types.h>
6538451Smsmith#include <sys/cdefs.h>
6638451Smsmith#include <sys/stat.h>
6759766Sjlemon#include <sys/dirent.h>
68223905Savatar
69223905Savatar/* this header intentionally exports NULL from <string.h> */
7064185Sjhb#include <string.h>
71329183Skevans#define strcoll(a, b)	strcmp((a), (b))
7238451Smsmith
73135576Sstefanf#define CHK(fmt, args...)	printf("%s(%d): " fmt "\n", __func__, __LINE__ , ##args)
74135576Sstefanf#define PCHK(fmt, args...)	{printf("%s(%d): " fmt "\n", __func__, __LINE__ , ##args); getchar();}
7539665Smsmith
7638451Smsmith#include <sys/errno.h>
7738451Smsmith
7838451Smsmith/* special stand error codes */
7938451Smsmith#define	EADAPT	(ELAST+1)	/* bad adaptor */
8038451Smsmith#define	ECTLR	(ELAST+2)	/* bad controller */
8138451Smsmith#define	EUNIT	(ELAST+3)	/* bad unit */
8238451Smsmith#define ESLICE	(ELAST+4)	/* bad slice */
8338451Smsmith#define	EPART	(ELAST+5)	/* bad partition */
8438451Smsmith#define	ERDLAB	(ELAST+6)	/* can't read disk label */
8538451Smsmith#define	EUNLAB	(ELAST+7)	/* unlabeled disk */
8638451Smsmith#define	EOFFSET	(ELAST+8)	/* relative seek not supported */
8738451Smsmith#define	ESALAST	(ELAST+8)	/* */
8838451Smsmith
89329175Skevans/* Partial signal emulation for sig_atomic_t */
90329175Skevans#include <machine/signal.h>
91329175Skevans
9238451Smsmithstruct open_file;
9338451Smsmith
9438451Smsmith/*
9538451Smsmith * This structure is used to define file system operations in a file system
9638451Smsmith * independent way.
9738451Smsmith *
9838451Smsmith * XXX note that filesystem providers should export a pointer to their fs_ops
9938451Smsmith *     struct, so that consumers can reference this and thus include the
10038451Smsmith *     filesystems that they require.
10138451Smsmith */
10238451Smsmithstruct fs_ops {
10339468Smsmith    const char	*fs_name;
10439468Smsmith    int		(*fo_open)(const char *path, struct open_file *f);
10538451Smsmith    int		(*fo_close)(struct open_file *f);
10638451Smsmith    int		(*fo_read)(struct open_file *f, void *buf,
10738451Smsmith			   size_t size, size_t *resid);
108332138Skevans    int		(*fo_write)(struct open_file *f, const void *buf,
10938451Smsmith			    size_t size, size_t *resid);
11038451Smsmith    off_t	(*fo_seek)(struct open_file *f, off_t offset, int where);
11138451Smsmith    int		(*fo_stat)(struct open_file *f, struct stat *sb);
11259766Sjlemon    int		(*fo_readdir)(struct open_file *f, struct dirent *d);
11338451Smsmith};
11438451Smsmith
11538451Smsmith/*
11638451Smsmith * libstand-supplied filesystems
11738451Smsmith */
11838451Smsmithextern struct fs_ops ufs_fsops;
11938451Smsmithextern struct fs_ops tftp_fsops;
12038451Smsmithextern struct fs_ops nfs_fsops;
12138451Smsmithextern struct fs_ops cd9660_fsops;
122235537Sgberextern struct fs_ops nandfs_fsops;
123108100Sjakeextern struct fs_ops gzipfs_fsops;
12483610Ssobomaxextern struct fs_ops bzipfs_fsops;
12538451Smsmithextern struct fs_ops dosfs_fsops;
12659766Sjlemonextern struct fs_ops ext2fs_fsops;
12792494Ssobomaxextern struct fs_ops splitfs_fsops;
128269361Smarcelextern struct fs_ops pkgfs_fsops;
12938451Smsmith
13038451Smsmith/* where values for lseek(2) */
13138451Smsmith#define	SEEK_SET	0	/* set file offset to offset */
13238451Smsmith#define	SEEK_CUR	1	/* set file offset to current plus offset */
13338451Smsmith#define	SEEK_END	2	/* set file offset to EOF plus offset */
13438451Smsmith
13538451Smsmith/*
13638451Smsmith * Device switch
13738451Smsmith */
13838451Smsmithstruct devsw {
13939468Smsmith    const char	dv_name[8];
14038451Smsmith    int		dv_type;		/* opaque type constant, arch-dependant */
141332154Skevans#define DEVT_NONE	0
142332154Skevans#define DEVT_DISK	1
143332154Skevans#define DEVT_NET	2
144332154Skevans#define DEVT_CD		3
145332154Skevans#define DEVT_ZFS	4
146332154Skevans#define DEVT_FD		5
14738451Smsmith    int		(*dv_init)(void);	/* early probe call */
148298230Sallanjude    int		(*dv_strategy)(void *devdata, int rw, daddr_t blk,
149313355Stsoome			size_t size, char *buf, size_t *rsize);
15038451Smsmith    int		(*dv_open)(struct open_file *f, ...);
15138451Smsmith    int		(*dv_close)(struct open_file *f);
15238451Smsmith    int		(*dv_ioctl)(struct open_file *f, u_long cmd, void *data);
153328889Skevans    int		(*dv_print)(int verbose);	/* print device information */
15464185Sjhb    void	(*dv_cleanup)(void);
15538451Smsmith};
15638451Smsmith
15759766Sjlemon/*
15859766Sjlemon * libstand-supplied device switch
15959766Sjlemon */
16059766Sjlemonextern struct devsw netdev;
16159766Sjlemon
16238451Smsmithextern int errno;
16338451Smsmith
164298230Sallanjude/*
165298230Sallanjude * Generic device specifier; architecture-dependent
166298230Sallanjude * versions may be larger, but should be allowed to
167298230Sallanjude * overlap.
168298230Sallanjude */
169332154Skevansstruct devdesc {
170298230Sallanjude    struct devsw	*d_dev;
171298230Sallanjude    int			d_unit;
172298230Sallanjude    void		*d_opendata;
173298230Sallanjude};
174298230Sallanjude
17538451Smsmithstruct open_file {
17638451Smsmith    int			f_flags;	/* see F_* below */
17738451Smsmith    struct devsw	*f_dev;		/* pointer to device operations */
17838451Smsmith    void		*f_devdata;	/* device specific data */
17938451Smsmith    struct fs_ops	*f_ops;		/* pointer to file system operations */
18038451Smsmith    void		*f_fsdata;	/* file system specific data */
18165470Smsmith    off_t		f_offset;	/* current file offset */
18265470Smsmith    char		*f_rabuf;	/* readahead buffer pointer */
18365470Smsmith    size_t		f_ralen;	/* valid data in readahead buffer */
18465470Smsmith    off_t		f_raoffset;	/* consumer offset in readahead buffer */
18565470Smsmith#define SOPEN_RASIZE	512
18638451Smsmith};
18738451Smsmith
188192679Sdfr#define	SOPEN_MAX	64
18938451Smsmithextern struct open_file files[];
19038451Smsmith
19138451Smsmith/* f_flags values */
19238451Smsmith#define	F_READ		0x0001	/* file opened for reading */
19338451Smsmith#define	F_WRITE		0x0002	/* file opened for writing */
19438451Smsmith#define	F_RAW		0x0004	/* raw device open - no file system */
19538451Smsmith#define F_NODEV		0x0008	/* network open - no device */
196329100Skevans#define	F_MASK		0xFFFF
197329100Skevans/* Mode modifier for strategy() */
198329100Skevans#define	F_NORA		(0x01 << 16)	/* Disable Read-Ahead */
19938451Smsmith
20055181Speter#define isascii(c)	(((c) & ~0x7F) == 0)
20138451Smsmith
20276579Sdcsstatic __inline int isupper(int c)
20376579Sdcs{
20476579Sdcs    return c >= 'A' && c <= 'Z';
20576579Sdcs}
20676579Sdcs
20776579Sdcsstatic __inline int islower(int c)
20876579Sdcs{
20976579Sdcs    return c >= 'a' && c <= 'z';
21076579Sdcs}
21176579Sdcs
21276579Sdcsstatic __inline int isspace(int c)
21376579Sdcs{
21476579Sdcs    return c == ' ' || (c >= 0x9 && c <= 0xd);
21576579Sdcs}
21676579Sdcs
21776579Sdcsstatic __inline int isdigit(int c)
21876579Sdcs{
21976579Sdcs    return c >= '0' && c <= '9';
22076579Sdcs}
22176579Sdcs
22276579Sdcsstatic __inline int isxdigit(int c)
22376579Sdcs{
22476579Sdcs    return isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
22576579Sdcs}
22676579Sdcs
22776579Sdcsstatic __inline int isalpha(int c)
22876579Sdcs{
22976579Sdcs    return isupper(c) || islower(c);
23076579Sdcs}
23176579Sdcs
23276579Sdcsstatic __inline int isalnum(int c)
23376579Sdcs{
23476579Sdcs    return isalpha(c) || isdigit(c);
23576579Sdcs}
23676579Sdcs
237329175Skevansstatic __inline int iscntrl(int c)
238329175Skevans{
239329175Skevans	return (c >= 0 && c < ' ') || c == 127;
240329175Skevans}
241329175Skevans
242329175Skevansstatic __inline int isgraph(int c)
243329175Skevans{
244329175Skevans	return c >= '!' && c <= '~';
245329175Skevans}
246329175Skevans
247329175Skevansstatic __inline int ispunct(int c)
248329175Skevans{
249329175Skevans	return (c >= '!' && c <= '/') || (c >= ':' && c <= '@') ||
250329175Skevans	    (c >= '[' && c <= '`') || (c >= '{' && c <= '~');
251329175Skevans}
252329175Skevans
25351169Sdfrstatic __inline int toupper(int c)
25451169Sdfr{
25551169Sdfr    return islower(c) ? c - 'a' + 'A' : c;
25651169Sdfr}
25751169Sdfr
25851169Sdfrstatic __inline int tolower(int c)
25951169Sdfr{
26051169Sdfr    return isupper(c) ? c - 'A' + 'a' : c;
26151169Sdfr}
26251169Sdfr
26339665Smsmith/* sbrk emulation */
26439665Smsmithextern void	setheap(void *base, void *top);
26539665Smsmithextern char	*sbrk(int incr);
26638451Smsmith
26739665Smsmithextern void	*reallocf(void *ptr, size_t size);
26839665Smsmithextern void	mallocstats(void);
26939665Smsmith
270100392Speterextern int	printf(const char *fmt, ...) __printflike(1, 2);
271346477Skevansextern int	asprintf(char **buf, const char *cfmt, ...) __printflike(2, 3);
272100392Speterextern int	sprintf(char *buf, const char *cfmt, ...) __printflike(2, 3);
273266878Shselaskyextern int	snprintf(char *buf, size_t size, const char *cfmt, ...) __printflike(3, 4);
274334935Sianextern int	vprintf(const char *fmt, __va_list);
275334935Sianextern int	vsprintf(char *buf, const char *cfmt, __va_list);
276334935Sianextern int	vsnprintf(char *buf, size_t size, const char *cfmt, __va_list);
27738451Smsmith
278276079Sianextern void	twiddle(u_int callerdiv);
279276079Sianextern void	twiddle_divisor(u_int globaldiv);
28038451Smsmith
28138451Smsmithextern void	ngets(char *, int);
28238451Smsmith#define gets(x)	ngets((x), 0)
28338451Smsmithextern int	fgetstr(char *buf, int size, int fd);
28438451Smsmith
28538451Smsmithextern int	open(const char *, int);
28638451Smsmith#define	O_RDONLY	0x0
28787632Sjhb#define O_WRONLY	0x1
28838451Smsmith#define O_RDWR		0x2
289344220Skevans/* NOT IMPLEMENTED */
290344220Skevans#define	O_CREAT		0x0200		/* create if nonexistent */
291344220Skevans#define	O_TRUNC		0x0400		/* truncate to zero length */
29238451Smsmithextern int	close(int);
29338451Smsmithextern void	closeall(void);
29438451Smsmithextern ssize_t	read(int, void *, size_t);
295332138Skevansextern ssize_t	write(int, const void *, size_t);
29659766Sjlemonextern struct	dirent *readdirfd(int);
29738451Smsmith
29838451Smsmithextern void	srandom(u_long seed);
299329114Skevansextern long	random(void);
30038451Smsmith
30138451Smsmith/* imports from stdlib, locally modified */
30238451Smsmithextern char	*optarg;			/* getopt(3) external variables */
30342511Smsmithextern int	optind, opterr, optopt, optreset;
30438451Smsmithextern int	getopt(int, char * const [], const char *);
30538451Smsmith
30638451Smsmith/* pager.c */
30738451Smsmithextern void	pager_open(void);
30838451Smsmithextern void	pager_close(void);
30938451Smsmithextern int	pager_output(const char *lines);
31039468Smsmithextern int	pager_file(const char *fname);
31138451Smsmith
31240891Smsmith/* No signal state to preserve */
31340891Smsmith#define setjmp	_setjmp
31440891Smsmith#define longjmp	_longjmp
31540891Smsmith
31638451Smsmith/* environment.c */
31738451Smsmith#define EV_DYNAMIC	(1<<0)		/* value was dynamically allocated, free if changed/unset */
31838451Smsmith#define EV_VOLATILE	(1<<1)		/* value is volatile, make a copy of it */
31938451Smsmith#define EV_NOHOOK	(1<<2)		/* don't call hook when setting */
32038451Smsmith
32138451Smsmithstruct env_var;
32238451Smsmithtypedef char	*(ev_format_t)(struct env_var *ev);
323121532Spetertypedef int	(ev_sethook_t)(struct env_var *ev, int flags,
324121532Speter		    const void *value);
32538451Smsmithtypedef int	(ev_unsethook_t)(struct env_var *ev);
32638451Smsmith
32738451Smsmithstruct env_var
32838451Smsmith{
32938451Smsmith    char		*ev_name;
33038451Smsmith    int			ev_flags;
33138451Smsmith    void		*ev_value;
33238451Smsmith    ev_sethook_t	*ev_sethook;
33338451Smsmith    ev_unsethook_t	*ev_unsethook;
33438451Smsmith    struct env_var	*ev_next, *ev_prev;
33538451Smsmith};
33638451Smsmithextern struct env_var	*environ;
33738451Smsmith
33838451Smsmithextern struct env_var	*env_getenv(const char *name);
33964185Sjhbextern int		env_setenv(const char *name, int flags,
34064185Sjhb				   const void *value, ev_sethook_t sethook,
34164185Sjhb				   ev_unsethook_t unsethook);
34238451Smsmithextern char		*getenv(const char *name);
34364185Sjhbextern int		setenv(const char *name, const char *value,
34464185Sjhb			       int overwrite);
345329114Skevansextern int		putenv(char *string);
34638451Smsmithextern int		unsetenv(const char *name);
34738451Smsmith
34838451Smsmithextern ev_sethook_t	env_noset;		/* refuse set operation */
34938451Smsmithextern ev_unsethook_t	env_nounset;		/* refuse unset operation */
35038451Smsmith
351329175Skevans/* stdlib.h routines */
352329175Skevansextern int		abs(int a);
353329175Skevansextern void		abort(void) __dead2;
354329175Skevansextern long		strtol(const char * __restrict, char ** __restrict, int);
355329175Skevansextern long long	strtoll(const char * __restrict, char ** __restrict, int);
356329175Skevansextern unsigned long	strtoul(const char * __restrict, char ** __restrict, int);
357329175Skevansextern unsigned long long strtoull(const char * __restrict, char ** __restrict, int);
358329175Skevans
35938451Smsmith/* BCD conversions (undocumented) */
36038451Smsmithextern u_char const	bcd2bin_data[];
36138451Smsmithextern u_char const	bin2bcd_data[];
36238451Smsmithextern char const	hex2ascii_data[];
36338451Smsmith
36438451Smsmith#define	bcd2bin(bcd)	(bcd2bin_data[bcd])
36538451Smsmith#define	bin2bcd(bin)	(bin2bcd_data[bin])
36638451Smsmith#define	hex2ascii(hex)	(hex2ascii_data[hex])
367329175Skevans#define	validbcd(bcd)	(bcd == 0 || (bcd > 0 && bcd <= 0x99 && bcd2bin_data[bcd] != 0))
36838451Smsmith
36938451Smsmith/* min/max (undocumented) */
37038451Smsmithstatic __inline int imax(int a, int b) { return (a > b ? a : b); }
37138451Smsmithstatic __inline int imin(int a, int b) { return (a < b ? a : b); }
37238451Smsmithstatic __inline long lmax(long a, long b) { return (a > b ? a : b); }
37338451Smsmithstatic __inline long lmin(long a, long b) { return (a < b ? a : b); }
37438451Smsmithstatic __inline u_int max(u_int a, u_int b) { return (a > b ? a : b); }
37538451Smsmithstatic __inline u_int min(u_int a, u_int b) { return (a < b ? a : b); }
37638451Smsmithstatic __inline quad_t qmax(quad_t a, quad_t b) { return (a > b ? a : b); }
37738451Smsmithstatic __inline quad_t qmin(quad_t a, quad_t b) { return (a < b ? a : b); }
37838451Smsmithstatic __inline u_long ulmax(u_long a, u_long b) { return (a > b ? a : b); }
37938451Smsmithstatic __inline u_long ulmin(u_long a, u_long b) { return (a < b ? a : b); }
38038451Smsmith
38138451Smsmith/* null functions for device/filesystem switches (undocumented) */
38238451Smsmithextern int	nodev(void);
38338451Smsmithextern int	noioctl(struct open_file *, u_long, void *);
38438451Smsmithextern void	nullsys(void);
38538451Smsmith
38639468Smsmithextern int	null_open(const char *path, struct open_file *f);
38738451Smsmithextern int	null_close(struct open_file *f);
38855137Speterextern int	null_read(struct open_file *f, void *buf, size_t size, size_t *resid);
389332138Skevansextern int	null_write(struct open_file *f, const void *buf, size_t size, size_t *resid);
39038451Smsmithextern off_t	null_seek(struct open_file *f, off_t offset, int where);
39138451Smsmithextern int	null_stat(struct open_file *f, struct stat *sb);
39259766Sjlemonextern int	null_readdir(struct open_file *f, struct dirent *d);
39338451Smsmith
39459766Sjlemon
39538451Smsmith/*
39638451Smsmith * Machine dependent functions and data, must be provided or stubbed by
39738451Smsmith * the consumer
39838451Smsmith */
399329175Skevansextern void		exit(int) __dead2;
40038451Smsmithextern int		getchar(void);
40138451Smsmithextern int		ischar(void);
40238451Smsmithextern void		putchar(int);
40339672Sdfrextern int		devopen(struct open_file *, const char *, const char **);
40438451Smsmithextern int		devclose(struct open_file *f);
405124570Sjhbextern void		panic(const char *, ...) __dead2 __printflike(1, 2);
406329175Skevansextern void		panic_action(void) __weak_symbol __dead2;
407329175Skevansextern time_t		getsecs(void);
40838451Smsmithextern struct fs_ops	*file_system[];
409269308Smarcelextern struct fs_ops	*exclusive_file_system;
41038451Smsmithextern struct devsw	*devsw[];
41138451Smsmith
41290868Smike/*
41390868Smike * Expose byteorder(3) functions.
41490868Smike */
41591959Smike#ifndef _BYTEORDER_PROTOTYPED
41691959Smike#define	_BYTEORDER_PROTOTYPED
41791959Smikeextern uint32_t		htonl(uint32_t);
41891959Smikeextern uint16_t		htons(uint16_t);
41991959Smikeextern uint32_t		ntohl(uint32_t);
42091959Smikeextern uint16_t		ntohs(uint16_t);
42191959Smike#endif
42291959Smike
42391959Smike#ifndef _BYTEORDER_FUNC_DEFINED
42491959Smike#define	_BYTEORDER_FUNC_DEFINED
42590868Smike#define	htonl(x)	__htonl(x)
42690868Smike#define	htons(x)	__htons(x)
42790868Smike#define	ntohl(x)	__ntohl(x)
42890868Smike#define	ntohs(x)	__ntohs(x)
42991959Smike#endif
43090868Smike
431100394Spetervoid *Malloc(size_t, const char *, int);
432100394Spetervoid *Calloc(size_t, size_t, const char *, int);
433100394Spetervoid *Realloc(void *, size_t, const char *, int);
434100394Spetervoid Free(void *, const char *, int);
43539672Sdfr
436329175Skevans#ifdef DEBUG_MALLOC
437100394Speter#define malloc(x)	Malloc(x, __FILE__, __LINE__)
438100394Speter#define calloc(x, y)	Calloc(x, y, __FILE__, __LINE__)
439100394Speter#define free(x)		Free(x, __FILE__, __LINE__)
440100394Speter#define realloc(x, y)	Realloc(x, y, __FILE__, __LINE__)
441100394Speter#else
442102216Sscottl#define malloc(x)	Malloc(x, NULL, 0)
443100394Speter#define calloc(x, y)	Calloc(x, y, NULL, 0)
444100394Speter#define free(x)		Free(x, NULL, 0)
445100394Speter#define realloc(x, y)	Realloc(x, y, NULL, 0)
44639672Sdfr#endif
447146327Sobrien
448146327Sobrien#endif	/* STAND_H */
449