2009-08-15 05:49:38 +00:00
|
|
|
// See ../src/lib9/LICENSE
|
|
|
|
|
2004-03-25 23:03:57 +00:00
|
|
|
#ifndef _U_H_
|
|
|
|
#define _U_H_ 1
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2004-12-25 22:00:27 +00:00
|
|
|
#define __BSD_VISIBLE 1 /* FreeBSD 5.x */
|
2005-07-27 13:06:50 +00:00
|
|
|
#if defined(__sun__)
|
|
|
|
# define __EXTENSIONS__ 1 /* SunOS */
|
2008-07-20 08:51:03 +00:00
|
|
|
# if defined(__SunOS5_6__) || defined(__SunOS5_7__) || defined(__SunOS5_8__) || defined(__SunOS5_9__) || defined(__SunOS5_10__)
|
2005-07-27 13:06:50 +00:00
|
|
|
/* NOT USING #define __MAKECONTEXT_V2_SOURCE 1 / * SunOS */
|
|
|
|
# else
|
2008-07-20 08:51:03 +00:00
|
|
|
/* What's left? */
|
2005-07-27 13:06:50 +00:00
|
|
|
# define __MAKECONTEXT_V2_SOURCE 1
|
|
|
|
# endif
|
|
|
|
#endif
|
2004-03-25 23:03:57 +00:00
|
|
|
#define _BSD_SOURCE 1
|
2005-03-28 15:58:14 +00:00
|
|
|
#define _NETBSD_SOURCE 1 /* NetBSD */
|
2004-03-25 23:03:57 +00:00
|
|
|
#define _SVID_SOURCE 1
|
2016-05-07 15:36:32 +00:00
|
|
|
#define _DEFAULT_SOURCE 1
|
2005-07-20 23:40:47 +00:00
|
|
|
#if !defined(__APPLE__) && !defined(__OpenBSD__)
|
2005-07-13 21:34:11 +00:00
|
|
|
# define _XOPEN_SOURCE 1000
|
|
|
|
# define _XOPEN_SOURCE_EXTENDED 1
|
|
|
|
#endif
|
2006-04-04 11:58:52 +00:00
|
|
|
#if defined(__FreeBSD__)
|
|
|
|
# include <sys/cdefs.h>
|
|
|
|
/* for strtoll */
|
|
|
|
# undef __ISO_C_VISIBLE
|
|
|
|
# define __ISO_C_VISIBLE 1999
|
|
|
|
# undef __LONG_LONG_SUPPORTED
|
|
|
|
# define __LONG_LONG_SUPPORTED
|
|
|
|
#endif
|
2009-07-15 05:55:52 +00:00
|
|
|
#if defined(__AIX__)
|
|
|
|
# define _XOPEN_SOURCE 1
|
|
|
|
#endif
|
2009-09-13 21:30:12 +00:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
# define _DARWIN_NO_64_BIT_INODE /* Snow Leopard */
|
|
|
|
#endif
|
2004-03-25 23:03:57 +00:00
|
|
|
#define _LARGEFILE64_SOURCE 1
|
|
|
|
#define _FILE_OFFSET_BITS 64
|
|
|
|
|
2005-07-20 23:40:47 +00:00
|
|
|
#include <inttypes.h>
|
2005-07-19 17:40:50 +00:00
|
|
|
|
2004-03-25 23:03:57 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <setjmp.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <math.h>
|
2004-04-19 18:13:05 +00:00
|
|
|
#include <ctype.h> /* for tolower */
|
2004-03-25 23:03:57 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* OS-specific crap
|
|
|
|
*/
|
|
|
|
#define _NEEDUCHAR 1
|
|
|
|
#define _NEEDUSHORT 1
|
|
|
|
#define _NEEDUINT 1
|
|
|
|
#define _NEEDULONG 1
|
|
|
|
|
|
|
|
typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
|
|
|
|
|
|
|
|
#if defined(__linux__)
|
|
|
|
# include <sys/types.h>
|
2005-03-15 16:12:51 +00:00
|
|
|
# if defined(__Linux26__)
|
|
|
|
# include <pthread.h>
|
|
|
|
# define PLAN9PORT_USING_PTHREADS 1
|
|
|
|
# endif
|
2004-03-25 23:03:57 +00:00
|
|
|
# if defined(__USE_MISC)
|
|
|
|
# undef _NEEDUSHORT
|
|
|
|
# undef _NEEDUINT
|
|
|
|
# undef _NEEDULONG
|
2004-09-21 01:11:28 +00:00
|
|
|
# endif
|
2004-12-25 22:00:27 +00:00
|
|
|
#elif defined(__sun__)
|
2004-03-25 23:03:57 +00:00
|
|
|
# include <sys/types.h>
|
2005-03-15 16:12:51 +00:00
|
|
|
# include <pthread.h>
|
|
|
|
# define PLAN9PORT_USING_PTHREADS 1
|
2004-03-25 23:03:57 +00:00
|
|
|
# undef _NEEDUSHORT
|
|
|
|
# undef _NEEDUINT
|
|
|
|
# undef _NEEDULONG
|
2005-03-15 16:12:51 +00:00
|
|
|
# define nil 0 /* no cast to void* */
|
2004-12-25 22:00:27 +00:00
|
|
|
#elif defined(__FreeBSD__)
|
2004-03-25 23:03:57 +00:00
|
|
|
# include <sys/types.h>
|
2004-12-29 01:32:42 +00:00
|
|
|
# include <osreldate.h>
|
2005-03-15 16:12:51 +00:00
|
|
|
# if __FreeBSD_version >= 500000
|
|
|
|
# define PLAN9PORT_USING_PTHREADS 1
|
|
|
|
# include <pthread.h>
|
|
|
|
# endif
|
2004-03-25 23:03:57 +00:00
|
|
|
# if !defined(_POSIX_SOURCE)
|
|
|
|
# undef _NEEDUSHORT
|
|
|
|
# undef _NEEDUINT
|
|
|
|
# endif
|
2004-12-25 22:00:27 +00:00
|
|
|
#elif defined(__APPLE__)
|
2004-03-25 23:03:57 +00:00
|
|
|
# include <sys/types.h>
|
2005-03-15 16:12:51 +00:00
|
|
|
# include <pthread.h>
|
|
|
|
# define PLAN9PORT_USING_PTHREADS 1
|
2005-05-07 22:41:59 +00:00
|
|
|
# if __GNUC__ < 4
|
|
|
|
# undef _NEEDUSHORT
|
|
|
|
# undef _NEEDUINT
|
|
|
|
# endif
|
|
|
|
# undef _ANSI_SOURCE
|
|
|
|
# undef _POSIX_C_SOURCE
|
2005-07-13 21:34:11 +00:00
|
|
|
# undef _XOPEN_SOURCE
|
2005-05-07 22:41:59 +00:00
|
|
|
# if !defined(NSIG)
|
|
|
|
# define NSIG 32
|
|
|
|
# endif
|
2004-03-25 23:03:57 +00:00
|
|
|
# define _NEEDLL 1
|
2005-03-28 15:58:14 +00:00
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
# include <sched.h>
|
|
|
|
# include <sys/types.h>
|
|
|
|
# undef _NEEDUSHORT
|
|
|
|
# undef _NEEDUINT
|
|
|
|
# undef _NEEDULONG
|
2005-05-01 18:40:01 +00:00
|
|
|
#elif defined(__OpenBSD__)
|
2005-07-19 11:36:27 +00:00
|
|
|
# include <sys/types.h>
|
2012-07-14 14:16:54 +00:00
|
|
|
# include <pthread.h>
|
|
|
|
# define PLAN9PORT_USING_PTHREADS 1
|
2005-05-01 18:40:01 +00:00
|
|
|
# undef _NEEDUSHORT
|
|
|
|
# undef _NEEDUINT
|
|
|
|
# undef _NEEDULONG
|
2004-12-25 22:00:27 +00:00
|
|
|
#else
|
|
|
|
/* No idea what system this is -- try some defaults */
|
2005-03-15 16:12:51 +00:00
|
|
|
# include <pthread.h>
|
2004-12-25 22:00:27 +00:00
|
|
|
# define PLAN9PORT_USING_PTHREADS 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef O_DIRECT
|
|
|
|
#define O_DIRECT 0
|
2004-03-25 23:03:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef signed char schar;
|
2004-04-19 05:52:43 +00:00
|
|
|
|
2004-03-25 23:03:57 +00:00
|
|
|
#ifdef _NEEDUCHAR
|
|
|
|
typedef unsigned char uchar;
|
|
|
|
#endif
|
|
|
|
#ifdef _NEEDUSHORT
|
|
|
|
typedef unsigned short ushort;
|
|
|
|
#endif
|
|
|
|
#ifdef _NEEDUINT
|
|
|
|
typedef unsigned int uint;
|
|
|
|
#endif
|
|
|
|
#ifdef _NEEDULONG
|
|
|
|
typedef unsigned long ulong;
|
|
|
|
#endif
|
|
|
|
typedef unsigned long long uvlong;
|
|
|
|
typedef long long vlong;
|
2005-07-19 17:40:50 +00:00
|
|
|
|
2012-02-19 23:11:39 +00:00
|
|
|
typedef uvlong u64int;
|
|
|
|
typedef vlong s64int;
|
2005-07-19 17:40:50 +00:00
|
|
|
typedef uint8_t u8int;
|
|
|
|
typedef int8_t s8int;
|
|
|
|
typedef uint16_t u16int;
|
|
|
|
typedef int16_t s16int;
|
|
|
|
typedef uintptr_t uintptr;
|
2008-03-06 20:13:42 +00:00
|
|
|
typedef intptr_t intptr;
|
2012-02-19 23:11:39 +00:00
|
|
|
typedef uint u32int;
|
|
|
|
typedef int s32int;
|
2004-03-25 23:03:57 +00:00
|
|
|
|
2010-02-08 00:51:28 +00:00
|
|
|
typedef u32int uint32;
|
|
|
|
typedef s32int int32;
|
|
|
|
typedef u16int uint16;
|
|
|
|
typedef s16int int16;
|
|
|
|
typedef u64int uint64;
|
|
|
|
typedef s64int int64;
|
2010-07-14 18:15:55 +00:00
|
|
|
typedef u8int uint8;
|
|
|
|
typedef s8int int8;
|
2010-02-08 00:51:28 +00:00
|
|
|
|
2004-03-25 23:03:57 +00:00
|
|
|
#undef _NEEDUCHAR
|
|
|
|
#undef _NEEDUSHORT
|
|
|
|
#undef _NEEDUINT
|
|
|
|
#undef _NEEDULONG
|
|
|
|
|
2005-01-04 21:18:08 +00:00
|
|
|
/*
|
|
|
|
* Funny-named symbols to tip off 9l to autolink.
|
|
|
|
*/
|
|
|
|
#define AUTOLIB(x) static int __p9l_autolib_ ## x = 1;
|
2005-10-29 17:36:49 +00:00
|
|
|
#define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x = 1;
|
2005-01-04 21:18:08 +00:00
|
|
|
|
2005-01-06 23:06:03 +00:00
|
|
|
/*
|
2005-05-07 22:41:59 +00:00
|
|
|
* Gcc is too smart for its own good.
|
2005-01-06 23:06:03 +00:00
|
|
|
*/
|
2005-05-07 22:41:59 +00:00
|
|
|
#if defined(__GNUC__)
|
2006-01-27 05:51:54 +00:00
|
|
|
# undef strcmp /* causes way too many warnings */
|
2005-05-07 22:41:59 +00:00
|
|
|
# if __GNUC__ >= 4 || (__GNUC__==3 && !defined(__APPLE_CC__))
|
2005-01-06 23:06:03 +00:00
|
|
|
# undef AUTOLIB
|
|
|
|
# define AUTOLIB(x) int __p9l_autolib_ ## x __attribute__ ((weak));
|
2005-10-29 17:36:49 +00:00
|
|
|
# undef AUTOFRAMEWORK
|
|
|
|
# define AUTOFRAMEWORK(x) int __p9l_autoframework_ ## x __attribute__ ((weak));
|
2005-05-02 18:08:03 +00:00
|
|
|
# else
|
|
|
|
# undef AUTOLIB
|
|
|
|
# define AUTOLIB(x) static int __p9l_autolib_ ## x __attribute__ ((unused));
|
2005-10-29 17:36:49 +00:00
|
|
|
# undef AUTOFRAMEWORK
|
|
|
|
# define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x __attribute__ ((unused));
|
2005-01-06 23:06:03 +00:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2004-03-25 23:03:57 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|