File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / libpdel / ports / Linux / hacks.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:25:53 2012 UTC (12 years, 4 months ago) by misho
Branches: libpdel, MAIN
CVS tags: v0_5_3, HEAD
libpdel


#define _XOPEN_SOURCE	600
#define _GNU_SOURCE	1
#define _BSD_SOURCE	1
#define _ISOC99_SOURCE	1

#include <string.h>		/* memcpy(), etc. */
#include <netinet/in.h>		/* htonl(), etc. */

/* Linux does not have these 'errno' values */
#define EFTYPE		EINVAL
#define EPROGMISMATCH	EINVAL

#define LLONG_MAX	9223372036854775807LL
#define LLONG_MIN	(-LLONG_MAX - 1LL)

#define	INFTIM		(-1)

#define REG_STARTEND	0

#define ALIGNBYTES		(sizeof(size_t) - 1)		/* ?? */
#define ALIGN(p)		(((unsigned)(p) + ALIGNBYTES) & ~ALIGNBYTES)

#define mergesort(a,b,c,d)	(qsort(a,b,c,d), 0)
#define strlcpy(dst, src, size)	snprintf(dst, size, "%s", src)
#define strlcat(dst, src, size)	snprintf((dst) + strlen(dst), \
				    (size) - strlen(dst), "%s", src)

#include <libio.h>
#define funopen1(c, m, rf, wf, sf, cf)					\
	fopencookie(c, m,						\
	    ({								\
		_IO_cookie_io_functions_t _funcs;			\
		_funcs.read = (cookie_read_function_t *)(rf);		\
		_funcs.write = (cookie_write_function_t *)(wf);		\
		_funcs.seek = (cookie_seek_function_t *)(sf);		\
		_funcs.close = (cookie_close_function_t *)(cf);		\
		_funcs;							\
	     }))
#define funopen(c, rf, wf, sf, cf) \
			funopen1(c, "r+", rf, wf, sf, cf)
#define fropen(c, rf)	funopen1(c, "r", rf, NULL, NULL, NULL)
#define fwopen(c, rf)	funopen1(c, "w", NULL, wf, NULL, NULL)


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>