[libimdb-commit] CVS: libimdb/include Makefile,NONE,1.1 sysincludes.h,NONE,1.1
Status: Pre-Alpha
Brought to you by:
jveldhuis
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:18:47
|
Update of /cvsroot/libimdb/libimdb/include
In directory sc8-pr-cvs1:/tmp/cvs-serv11812/include
Added Files:
Makefile sysincludes.h
Log Message:
initial checkin
--- NEW FILE: Makefile ---
#
# $Id: Makefile,v 1.1 2003/06/16 04:18:37 jveldhuis Exp $
#
include ../config.mk
include ../constants.mk
SUBPROJECTS = jlog
build clean clobber depend install:
@for sub in $(SUBPROJECTS); do \
[ -d $$sub ] || continue; \
echo "`$(DATECMD)`: $@ing $$sub"; \
(cd $$sub; $(MAKE) $@) || exit 1; \
done; \
--- NEW FILE: sysincludes.h ---
/**
@file
An attempt to hide some cross system and cross compiler issues like what
system includes are required.
Because we don't write testing code for all cases, support in each _USE_
definition is fixed/added on a needed basis, the framework here should
minimize code compatibily when new support is added.
History: we chose _USE_??? because this doesn't seem to colide with other
software projects and __USE_?? appears in system specific includes for things
like __USE_POSIX and __USE_XOPEN. We try to be similar but not conflict.
We should/could probably undef all _USE_ defines at the end of this file, but
this allows the use of these definitions after the include directive to do
code switching... not that this is neccessarily useful.
Supports the follow defined systems:
- SOLARIS5 (solaris 2.5.x)
- SOLARIS7 (solaris 2.7.x)
- NATIVE_WINDOWS (windows includes)
- LINUX (only tested with RH 7.[13])
@todo how can we enforce that we use INLINE and __FUNC__ and
__PRETTY_FUNC__ ?
@verbatim $Id: sysincludes.h,v 1.1 2003/06/16 04:18:37 jveldhuis Exp $ @endverbatim
*/
#ifndef SYSINCLUDES_H
# define SYSINCLUDES_H
/******************************************************************************/
/** @def INSIGHT_SET_OPTION
This is parasoft software specific and is here only out of convienece
*/
#ifdef __INSIGHT__
#define INSIGHT_SET_OPTION(option, value) _Insight_set_option(option, value);
#else
#define INSIGHT_SET_OPTION(option, value)
#endif
/**
Here completely out out of convienece, disables __attribute_ defintions
for non-gnuc compilers.
*/
#ifndef __GNUC__
#define __attribute__(def)
#endif
/* from assert.h in RH's glibc-devel-2.2.4-31:
------------------------------------------
Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
which contains the name of the function currently being defined.
This is broken in G++ before version 2.6.
C9x has a similar variable called __func__, but prefer the GCC one since
it demangles C++ function names.
*/
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ == 199901L)
#define __FUNC__ __func__
#define __PRETY_FUNC__ __func__
#elif defined(__GNUC__)
#define __FUNC__ __FUNCTION__
#define __PRETY_FUNC__ __PRETTY_FUNCTION__
#else /* __STDC_VERSION__ && __GNUC__ */
#define __FUNC__ NULL
#define __PRETTY_FUNC__ NULL
#endif /* __STDC_VERSION__ && __GNUC__ */
/* define INLINE, I suspect the keyword is __inline for
M$'s cl and cxx, but I'm not sure - jwv */
#if defined(__GNUC__)
#define INLINE inline
#else /* __STDC__ && __cplusplus */
#error "INLINE is not defined for this compiler"
#endif /* __STDC__ && __cplusplus */
#if defined(MPATROL)
# include "/usr/local/include/mpatrol.h"
#endif
/**
@def _USE_STDIO
Standard io definitions.
NULL, FILE, fprintf, stderr, unlink, putenv etc
*/
#if defined(_USE_STDIO)
# include <stdio.h>
# ifdef NATIVE_WINDOWS
# define tempnam _tempnam
# define unlink _unlink
# endif
#endif
/******************************************************************************/
/**
@def _USE_STDLIB
Standard library definitions.
includes: exit, abort, ato*, abs, strtod, strtol, strtoul, system, rand,
getenv, putenv, getpagesize, getpid, sleep
*/
#if defined(_USE_STDLIB)
# include <stdlib.h>
# if !defined(NATIVE_WINDOWS)
# include <unistd.h>
# endif
# if defined(NATIVE_WINDOWS)
# include <process.h> /* for getpid */
# define getpid _getpid
# define sleep(sec) Sleep(sec*1000)
# define putenv _putenv
/*
* get option letter from argument vector
*/
extern int opterr, optind, optopt;
extern char *optarg;
int
getopt(int nargc, char** nargv, char* ostr);
# endif
# ifdef SOLARIS5
extern int getpagesize(void);
# endif
#endif
/**
@def _USE_ERRNO
Standard system errno functions and definitions.
includes: errno, sys_nerr...
*/
#if defined(_USE_ERRNO)
# include <errno.h>
# if defined(SOLARIS5)
extern int sys_nerr;
# endif
#endif
/**
@def _USE_STDARG
Standard argument parsing functions and defintions.
includes: va_list, va_start, va_arg, va_end..
*/
#if defined(_USE_STDARG)
# include <stdarg.h>
#endif
/**
@def _USE_STRINGS
Standard string allocation, manipulation functions and definitions.
includes: strlen, strncmp, strcspn, strdup, strtok, snprintf, vsnprintf
*/
#if defined(_USE_STRING)
/* common typo :) */
# error "you specied _USE_STRING, you probably want _USE_STRINGS"
#endif
#if defined(_USE_STRINGS)
# include <string.h>
# ifdef NATIVE_WINDOWS
# define strncasecmp _strnicmp
# define strcasecmp _stricmp
# define strdup _strdup
# endif
# if defined(SOLARIS5)
# define snprintf __snprintf
# define vsnprintf __snprintf
# if defined(_USE_STDARG)
extern int snprintf(char *s, int len, char *fmt, ...);
/*extern int snprintf(char *s, int len, char *fmt, va_list args);*/
# endif
# elif defined(NATIVE_WINDOWS)
# define snprintf _snprintf
# define vsnprintf _vsnprintf
# endif
#endif
/**
@def _USE_BYTEORDER
Standard byte order related functions and definitions.
includes htonl, nltoh, htons...
(use to be USE_ENDIAN)
*/
#if defined(_USE_BYTEORDER)
# if defined(NATIVE_WINDOWS)
# include <winsock2.h>
# endif
# if defined(LINUX)
# include <endian.h> /* definitions */
# include <netinet/in.h> /* htonl and the like */
# endif
# if defined(SOLARIS)
# include <sys/types.h> /* definitions */
# include <netinet/in.h>
# include <inttypes.h>
# include <sys/byteorder.h>
# endif
#endif
/**
@def _USE_TYPES
Standard useful type definitions.
includes: mode_t things typically in types.h
*/
#if defined(_USE_TYPE)
/* common typo :) */
# error "you specied _USE_TYPE, you probably want _USE_TYPES"
#endif
#if defined(_USE_TYPES)
# ifdef NATIVE_WINDOWS
# include <winsock2.h> /* u_char, u_short, u_int, u_long */
# include <native.h> /* int64_t etc */
typedef u_int mode_t;
typedef int pid_t;
# define umask _umask
# else
# include <sys/types.h> /* int64_t */
typedef u_int SOCKET;
# if defined(LINUX)
# include <linux/types.h>
# endif
# if defined(SOLARIS5) || defined (SOLARIS7) || defined(LINUX)
/*# define int64_t long long*/
# endif
# if defined(LINUX)
# include <stdint.h> /* works under linux for uint32_t etc */
# endif
# endif
#endif
/**
@def _USE_SOCKETS
Standard socket functions and definitions.
include: sockaddr_in struct and BSD sockets - select, connect ..
*/
#if defined(_USE_SOCKETS)
#ifndef _USE_TYPES
# error "_USE_SOCKETS requires that you also define _USE_TYPES"
#endif
#ifndef _USE_SELECT
# error "_USE_SOCKETS requires that you also define _USE_SELECT"
#endif
# if defined(NATIVE_WINDOWS)
# include <winsock2.h>
# else
# define SOCKET_ERROR -1 /**< cross platform failure check on return code from
socket() */
# define INVALID_SOCKET (SOCKET)(~0)
# define closesocket(s) close(s) /**< useful for crossplatform use */
# include <sys/socket.h>
# include <rpc/rpc.h>
# include <rpc/pmap_clnt.h> /* for pmap_unset */
# include <fcntl.h> /* for fcntl() */
# endif
#endif
/**
@def _USE_RPC
Sun RPC functions.
*/
#if defined(_USE_RPC)
# if defined(NATIVE_WINDOWS)
# else
# include <rpc/rpc.h>
# include <rpc/pmap_clnt.h> /* for pmap_unset */
# endif
#endif
/**
@def _USE_SELECT
File Descript select() function and declarations
*/
#if defined(_USE_SELECT)
# if !defined(NATIVE_WINDOWS)
# include <sys/select.h>
# endif
#endif
/**
@def _USE_CTYPE
Standard character macros/functions defines.
includes; isupper, islower, toupper, tolower...
*/
#if defined(_USE_CTYPE)
# include <ctype.h>
# ifdef NATIVE_WINDOWS
# define isascii __isascii
# endif
#endif
/**
@def _USE_STAT
Standard file/directory statistic and management defines,functions etc.
includes:stat, fstat, mkdir
*/
#if defined(_USE_STAT)
# include <sys/stat.h>
# ifdef NATIVE_WINDOWS
# include <direct.h> /* for mkdir */
#
/** @def STRUCT_STAT
Useful for crossplatform stat() support */
# define STRUCT_STAT struct _stat
# define STAT _stat
# define FSTAT _fstat
/** @def S_ISDIR - apparently missing from windows :) */
# define S_ISDIR(_m) (((_m) & _S_IFMT) == _S_IFDIR)
#else
/** @def STRUCT_STAT
Useful for crossplatform stat() support */
# define STRUCT_STAT struct stat
# define STAT stat
# define FSTAT fstat
# endif
#endif
/**
@def _USE_IO
Advanced (ha) io functions and definition
includes: open, read/write,close,fileno, fdopen...
*/
#if defined(_USE_IO)
# if !defined(NATIVE_WINDOWS)
# include <unistd.h>
# endif
# if defined(NATIVE_WINDOWS)
# define access _access
# define open _open
# define close _close
# define read _read
# define write _write
# define fileno _fileno
# define fdopen _fdopen
# define ftruncate _chsize
# define popen _popen
# define pclose _pclose
# define F_OK 00
# define W_OK 02
# define R_OK 04
# include <io.h>
# include <sys/locking.h>
# define O_RDONLY _O_RDONLY
# define O_WRONLY _O_WRONLY
# define O_RDWR _O_RDWR
# define O_APPEND _O_APPEND
# define O_CREAT _O_CREAT
# define O_TRUNC _O_TRUNC
# define O_EXCL _O_EXCL
# define O_BINARY _O_BINARY
# include <sys/stat.h> /* for S_IREAD and S_IWRITE */
# else
# define O_BINARY 0
# ifndef S_IREAD
# define S_IREAD S_IRUSR
# define S_IWRITE S_IWUSR
# endif
# endif
# include <fcntl.h>
/** @def OPEN
crossplatform OPEN is here to ease cross platform #ifdef head-aches
*/
# if defined(NATIVE_WINDOWS)
# define OPEN(file, flags, unixmode, winmode) open(file, flags, winmode)
# else
# define OPEN(file, flags, unixmode, winmode) open(file, flags, unixmode)
# endif
#endif
/**
@def _USE_SIGNAL
System V - signal functions.
include: signal...
*/
#if defined(_USE_SIGNAL)
# include <signal.h>
#endif
/**
@def _USE_WAIT
Wait and friends.
includes: wait, waitpid
*/
#if defined(_USE_WAIT)
# if !defined(NATIVE_WINDOWS)
# include <sys/wait.h>
# endif
#endif
/**
@def _USE_TERMIO
Tty control functions, defines etc.
includes: ioctl and tty...
*/
#if defined(_USE_TERMIO)
# if !defined(NATIVE_WINDOWS)
# include <sys/ioctl.h>
# endif
# if defined(SOLARIS5) || defined(SOLARIS7)
# include <termios.h>
# endif
#endif
/**
@def _USE_NETDB
Network database queries, hostname lookups etc.
include: gethostbyname...
*/
#if defined(_USE_NETDB)
# if defined(NATIVE_WINDOWS)
# include <winsock2.h> /* for struct hostent etc */
# else
# include <netdb.h>
# endif
#endif
/**
@def _USE_UNAME
get name and information about current kernel
includes: uname
*/
#if defined(_USE_UNAME)
# if !defined(NATIVE_WINDOWS)
# include <sys/utsname.h>
# endif
#endif
/**
@def _USE_SETJMP
Setjmp and friends.
*/
#if defined(_USE_SETJMP)
# include <setjmp.h>
#endif
/**
@def _USE_TIME
Time functions and defines
*/
#if defined(_USE_TIME)
# if defined(NATIVE_WINDOWS)
# include <time.h>
# include <sys/timeb.h>
# define STRUCT_TIMEB struct _timeb
# define ftime _ftime
# else
# include <time.h>
# include <sys/time.h>
# include <sys/timeb.h>
# define STRUCT_TIMEB struct timeb
# endif
#endif
/**
@def _USE_MALLOC
Memory managment functions/defines.
includes: malloc, free, realloc, heap/mallocinfo
*/
#if defined(_USE_MALLOC)
# if defined(NATIVE_WINDOWS)
# define alloca _alloca
# endif
# if !defined(MPATROL)
# include <malloc.h>
# endif
#endif
/**
@def _USE_MMAP
Mmap and friends.
*/
#if defined(_USE_MMAP)
# if !defined(NATIVE_WINDOWS)
# include <sys/mman.h>
# endif
#endif
/**
@def _USE_ASSERT
lovely assert() function :)
*/
#if defined(_USE_ASSERT)
# include <assert.h>
#endif
/**
@def _USE_MEMORY
Memory modification functions.
include: memset, memcpy, memcmp...
*/
#if defined(_USE_MEMORY)
# include <memory.h>
#endif
/**
@def _USE_DYNAMIC_LIBS
Dynamic library management.
include: dlopen, dlclose, dlsym, dlerror...
*/
#if defined(_USE_DYNAMIC_LIBS)
# if !defined(NATIVE_WINDOWS)
# include <dlfcn.h>
# endif
#endif
/**
@def _USE_READDIR
Diretory information services.
include:opendir, closedir, readdir...
*/
#if defined(_USE_READDIR)
# if !defined(NATIVE_WINDOWS)
# include <dirent.h>
# endif
#endif
/**
@def _USE_SYSLOG
Syslog routines.
*/
#if defined(_USE_SYSLOG)
#ifndef _USE_TYPES
# error "_USE_SYSLOG requires that you also define _USE_TYPES"
#endif
# if !defined(NATIVE_WINDOWS)
# include <syslog.h>
# endif
#endif
/**
@def _USE_PWD
password entry information.
includes: getpwnam, getpwuid...
*/
#if defined(_USE_PWD)
# if defined(NATIVE_WINDOWS)
# include <windows.h>
# else
# include <pwd.h>
# endif
#endif
/**
@def _USE_GROUP
User group entry information.
includes:getgrgid, getgrnam, getgroups...
*/
#if defined(_USE_GROUP)
# if !defined(NATIVE_WINDOWS)
# include <unistd.h> /* for getgroups */
# include <grp.h>
# endif
#endif
/**
@def _USE_LIMITS
Catchall for Size limitations.
includes MAXPATHLEN, HOSTNAME_LEN, LOGINNAME_LEN, INT_MIN, INT_MAX,
UINT_MAX, INT8_MAX, UINT8_MAX, INT32_MAX, UINT32_MAX, INT64_MAX,
UINT64_MAX...
*/
#if defined(_USE_LIMITS)
# include <limits.h>
# if defined(NATIVE_WINDOWS)
# define MAXPATHLEN _MAX_PATH
#
# include <windows.h>
# include <winbase.h> /* for MAX_COMPUTERNAME_LENGTH */
# include <lmcons.h> /* for UNLEN */
# define HOSTNAME_LEN MAX_COMPUTERNAME_LENGTH + 1
# define GROUPNAME_LEN 256 /* should be fixed later */
# define LOGINNAME_LEN UNLEN+1 /* defined size for GetUserName */
# else
# if defined(SOLARIS7)
# include <netdb.h> /* for MAXHOSTNAMELEN */
# endif
# include <sys/param.h>
# define MAXINT INT_MAX
# define HOSTNAME_LEN MAXHOSTNAMELEN+1
# define GROUPNAME_LEN 256
# define LOGINNAME_LEN 256 /**< L_cuserid is only defined length for usernames on unix
but this (usually 9) seems too small, so we defined ours
to be bigger */
# endif
/*
# ifdef LINUX
# define INT8_MAX 127
# define UINT8_MAX 255U
# define INT32_MAX 2147483647
# define UINT32_MAX 4294967295U
# define INT64_MAX (9223372036854775807L)
# define UINT64_MAX (18446744073709551615UL)
# endif
*/
#endif
/* functions from misc library */
#if defined(_USE_STRINGS) && defined(_USE_TYPES)
char *
lltostr(int64_t x, char *ptr);
int64_t
strtoll(const char *s, char **ptr, int base);
#endif /* _USE_STRINGS && _USE_TYPES */
/**
@def _USE_MISC
Enable misc library functions that are missing from os to os
These appear here out of convienence.
*/
#if defined(_USE_MISC)
char *basename(char *pathname, char *buf);
# ifdef _USE_STRINGS
int strprefix(char *s, char *prefix, char **after);
# endif
# ifdef _USE_STDARG
int vsnprintf (char *str, size_t count, const char *fmt, va_list args);
int vasprintf(char **ptr, const char *format, va_list ap);
int asprintf(char **ptr, const char *format, ...);
# endif
int snprintf(char *str,size_t count,const char *fmt,...);
#endif
#ifdef DOXYGEN
/* these defines are only here to trigger doxygen documenation
generatation, because if they're not defined, doxygen complains
(Warning: documentation for unknown define _USE_TERMIO found)
We of course don't define these in this include, but we want
to docuemnt them here :)
*/
#define _USE_STDIO
#define _USE_STDLIB
#define _USE_ERRNO
#define _USE_STDARG
#define _USE_STRINGS
#define _USE_BYTEORDER
#define _USE_TYPES
#define _USE_SOCKETS
#define _USE_RPC
#define _USE_SELECT
#define _USE_CTYPE
#define _USE_STAT
#define _USE_IO
#define _USE_SIGNAL
#define _USE_WAIT
#define _USE_TERMIO
#define _USE_NETDB
#define _USE_UNAME
#define _USE_SETJMP
#define _USE_TIME
#define _USE_MALLOC
#define _USE_MMAP
#define _USE_ASSERT
#define _USE_MEMORY
#define _USE_DYNAMIC_LIBS
#define _USE_READDIR
#define _USE_SYSLOG
#define _USE_PWD
#define _USE_GROUP
#define _USE_LIMITS
#define _USE_MISC
#endif /* DOXYGEN */
#endif /* SYSINCLUDES_H */
|