VirtualBox

Changeset 46024 in vbox for trunk/include


Ignore:
Timestamp:
May 13, 2013 3:36:03 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
85691
Message:

iprt/cdefs.h: Added RT_OPSYS and RT_OPSYS_XXX, a value based version of RT_OS_XXXX that'll work outside #if statemtns.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/cdefs.h

    r45968 r46024  
    3232 */
    3333
    34 /*
    35  * Include sys/cdefs.h if present, if not define the stuff we need.
    36  */
    37 #ifdef HAVE_SYS_CDEFS_H
    38 # if defined(RT_ARCH_LINUX) && defined(__KERNEL__)
    39 #  error "oops"
    40 # endif
    41 # include <sys/cdefs.h>
    42 #else
    43 
    4434/** @def RT_C_DECLS_BEGIN
    4535 * Used to start a block of function declarations which are shared
     
    5242 */
    5343
    54 # if defined(__cplusplus)
    55 #  define RT_C_DECLS_BEGIN extern "C" {
    56 #  define RT_C_DECLS_END   }
    57 # else
    58 #  define RT_C_DECLS_BEGIN
    59 #  define RT_C_DECLS_END
    60 # endif
    61 
     44#if defined(__cplusplus)
     45# define RT_C_DECLS_BEGIN extern "C" {
     46# define RT_C_DECLS_END   }
     47#else
     48# define RT_C_DECLS_BEGIN
     49# define RT_C_DECLS_END
    6250#endif
    6351
     
    282270# endif
    283271#endif
     272
     273
     274
     275/** @name RT_OPSYS_XXX - Operative System Identifiers.
     276 * These are the value that the RT_OPSYS \#define can take. @{
     277 */
     278/** Unknown OS. */
     279#define RT_OPSYS_UNKNOWN    0
     280/** OS Agnostic. */
     281#define RT_OPSYS_AGNOSTIC   1
     282/** Darwin - aka Mac OS X. */
     283#define RT_OPSYS_DARWIN     2
     284/** DragonFly BSD. */
     285#define RT_OPSYS_DRAGONFLY  3
     286/** DOS. */
     287#define RT_OPSYS_DOS        4
     288/** FreeBSD. */
     289#define RT_OPSYS_FREEBSD    5
     290/** Haiku. */
     291#define RT_OPSYS_HAIKU      6
     292/** Linux. */
     293#define RT_OPSYS_LINUX      7
     294/** L4. */
     295#define RT_OPSYS_L4         8
     296/** Minix. */
     297#define RT_OPSYS_MINIX      9
     298/** NetBSD. */
     299#define RT_OPSYS_NETBSD     11
     300/** Netware. */
     301#define RT_OPSYS_NETWARE    12
     302/** NT (native). */
     303#define RT_OPSYS_NT         13
     304/** OpenBSD. */
     305#define RT_OPSYS_OPENBSD    14
     306/** OS/2. */
     307#define RT_OPSYS_OS2        15
     308/** Plan 9. */
     309#define RT_OPSYS_PLAN9      16
     310/** QNX. */
     311#define RT_OPSYS_QNX        17
     312/** Solaris. */
     313#define RT_OPSYS_SOLARIS    18
     314/** UEFI. */
     315#define RT_OPSYS_UEFI       19
     316/** Windows. */
     317#define RT_OPSYS_WINDOWS    20
     318/** The max RT_OPSYS_XXX value (exclusive). */
     319#define RT_OPSYS_MAX        21
     320/** @} */
     321
     322/** @def RT_OPSYS
     323 * Indicates which OS we're targetting. It's a \#define with is
     324 * assigned one of the RT_OPSYS_XXX defines above.
     325 *
     326 * So to test if we're on FreeBSD do the following:
     327 * @code
     328 *  #if RT_OPSYS == RT_OPSYS_FREEBSD
     329 *  some_funky_freebsd_specific_stuff();
     330 *  #endif
     331 * @endcode
     332 */
     333#ifndef RT_OPSYS
     334# if defined(__APPLE__)             || defined(RT_OS_DARWIN)
     335#  define RT_OPSYS      RT_OPSYS_DARWIN
     336# elif defined(__DragonFly__)       || defined(RT_OS_DRAGONFLY)
     337#  define RT_OPSYS      RT_OPSYS_DRAGONFLY
     338# elif defined(__FreeBSD__) /*??*/  || defined(RT_OS_FREEBSD)
     339#  define RT_OPSYS      RT_OPSYS_FREEBSD
     340# elif defined(__gnu_linux__)       || defined(RT_OS_LINUX)
     341#  define RT_OPSYS      RT_OPSYS_LINUX
     342# elif defined(__NetBSD__) /*??*/   || defined(RT_OS_NETBSD)
     343#  define RT_OPSYS      RT_OPSYS_NETBSD
     344# elif defined(__OpenBSD__) /*??*/  || defined(RT_OS_OPENBSD)
     345#  define RT_OPSYS      RT_OPSYS_OPENBSD
     346# elif defined(__OS2__)             || defined(RT_OS_OS2)
     347#  define RT_OPSYS      RT_OPSYS_OS2
     348# elif defined(__sun__) || defined(__SunOS__) || defined(__sun) || defined(__SunOS) || defined(RT_OS_SOLARIS)
     349#  define RT_OPSYS      RT_OPSYS_SOLARIS
     350# elif defined(_WIN32) || defined(_WIN64) || defined(RT_OS_WINDOWS)
     351#  define RT_OPSYS      RT_OPSYS_WINDOWS
     352# else
     353#  error "Port Me"
     354# endif
     355#endif
     356#if RT_OPSYS < RT_OPSYS_UNKNOWN || RT_OPSYS >= RT_OPSYS_MAX
     357# error "Invalid RT_OPSYS value."
     358#endif
     359
     360/*
     361 * Do some consistency checks.
     362 *
     363 * Search:  #define RT_OPSYS_([A-Z0-9]+) .*
     364 * Replace: #if defined(RT_OS_\1) && RT_OPSYS != RT_OPSYS_\1\n# error RT_OPSYS vs RT_OS_\1\n#endif
     365 */
     366#if defined(RT_OS_UNKNOWN) && RT_OPSYS != RT_OPSYS_UNKNOWN
     367# error RT_OPSYS vs RT_OS_UNKNOWN
     368#endif
     369#if defined(RT_OS_AGNOSTIC) && RT_OPSYS != RT_OPSYS_AGNOSTIC
     370# error RT_OPSYS vs RT_OS_AGNOSTIC
     371#endif
     372#if defined(RT_OS_DARWIN) && RT_OPSYS != RT_OPSYS_DARWIN
     373# error RT_OPSYS vs RT_OS_DARWIN
     374#endif
     375#if defined(RT_OS_DRAGONFLY) && RT_OPSYS != RT_OPSYS_DRAGONFLY
     376# error RT_OPSYS vs RT_OS_DRAGONFLY
     377#endif
     378#if defined(RT_OS_DOS) && RT_OPSYS != RT_OPSYS_DOS
     379# error RT_OPSYS vs RT_OS_DOS
     380#endif
     381#if defined(RT_OS_FREEBSD) && RT_OPSYS != RT_OPSYS_FREEBSD
     382# error RT_OPSYS vs RT_OS_FREEBSD
     383#endif
     384#if defined(RT_OS_HAIKU) && RT_OPSYS != RT_OPSYS_HAIKU
     385# error RT_OPSYS vs RT_OS_HAIKU
     386#endif
     387#if defined(RT_OS_LINUX) && RT_OPSYS != RT_OPSYS_LINUX
     388# error RT_OPSYS vs RT_OS_LINUX
     389#endif
     390#if defined(RT_OS_L4) && RT_OPSYS != RT_OPSYS_L4
     391# error RT_OPSYS vs RT_OS_L4
     392#endif
     393#if defined(RT_OS_MINIX) && RT_OPSYS != RT_OPSYS_MINIX
     394# error RT_OPSYS vs RT_OS_MINIX
     395#endif
     396#if defined(RT_OS_NETBSD) && RT_OPSYS != RT_OPSYS_NETBSD
     397# error RT_OPSYS vs RT_OS_NETBSD
     398#endif
     399#if defined(RT_OS_NETWARE) && RT_OPSYS != RT_OPSYS_NETWARE
     400# error RT_OPSYS vs RT_OS_NETWARE
     401#endif
     402#if defined(RT_OS_NT) && RT_OPSYS != RT_OPSYS_NT
     403# error RT_OPSYS vs RT_OS_NT
     404#endif
     405#if defined(RT_OS_OPENBSD) && RT_OPSYS != RT_OPSYS_OPENBSD
     406# error RT_OPSYS vs RT_OS_OPENBSD
     407#endif
     408#if defined(RT_OS_OS2) && RT_OPSYS != RT_OPSYS_OS2
     409# error RT_OPSYS vs RT_OS_OS2
     410#endif
     411#if defined(RT_OS_PLAN9) && RT_OPSYS != RT_OPSYS_PLAN9
     412# error RT_OPSYS vs RT_OS_PLAN9
     413#endif
     414#if defined(RT_OS_QNX) && RT_OPSYS != RT_OPSYS_QNX
     415# error RT_OPSYS vs RT_OS_QNX
     416#endif
     417#if defined(RT_OS_SOLARIS) && RT_OPSYS != RT_OPSYS_SOLARIS
     418# error RT_OPSYS vs RT_OS_SOLARIS
     419#endif
     420#if defined(RT_OS_UEFI) && RT_OPSYS != RT_OPSYS_UEFI
     421# error RT_OPSYS vs RT_OS_UEFI
     422#endif
     423#if defined(RT_OS_WINDOWS) && RT_OPSYS != RT_OPSYS_WINDOWS
     424# error RT_OPSYS vs RT_OS_WINDOWS
     425#endif
     426
     427/*
     428 * Make sure the RT_OS_XXX macro is defined.
     429 *
     430 * Search:  #define RT_OPSYS_([A-Z0-9]+) .*
     431 * Replace: #elif RT_OPSYS == RT_OPSYS_\1\n# ifndef RT_OS_\1\n#  define RT_OS_\1\n# endif
     432 */
     433#if RT_OPSYS == RT_OPSYS_UNKNOWN
     434# ifndef RT_OS_UNKNOWN
     435#  define RT_OS_UNKNOWN
     436# endif
     437#elif RT_OPSYS == RT_OPSYS_AGNOSTIC
     438# ifndef RT_OS_AGNOSTIC
     439#  define RT_OS_AGNOSTIC
     440# endif
     441#elif RT_OPSYS == RT_OPSYS_DARWIN
     442# ifndef RT_OS_DARWIN
     443#  define RT_OS_DARWIN
     444# endif
     445#elif RT_OPSYS == RT_OPSYS_DRAGONFLY
     446# ifndef RT_OS_DRAGONFLY
     447#  define RT_OS_DRAGONFLY
     448# endif
     449#elif RT_OPSYS == RT_OPSYS_DOS
     450# ifndef RT_OS_DOS
     451#  define RT_OS_DOS
     452# endif
     453#elif RT_OPSYS == RT_OPSYS_FREEBSD
     454# ifndef RT_OS_FREEBSD
     455#  define RT_OS_FREEBSD
     456# endif
     457#elif RT_OPSYS == RT_OPSYS_HAIKU
     458# ifndef RT_OS_HAIKU
     459#  define RT_OS_HAIKU
     460# endif
     461#elif RT_OPSYS == RT_OPSYS_LINUX
     462# ifndef RT_OS_LINUX
     463#  define RT_OS_LINUX
     464# endif
     465#elif RT_OPSYS == RT_OPSYS_L4
     466# ifndef RT_OS_L4
     467#  define RT_OS_L4
     468# endif
     469#elif RT_OPSYS == RT_OPSYS_MINIX
     470# ifndef RT_OS_MINIX
     471#  define RT_OS_MINIX
     472# endif
     473#elif RT_OPSYS == RT_OPSYS_NETBSD
     474# ifndef RT_OS_NETBSD
     475#  define RT_OS_NETBSD
     476# endif
     477#elif RT_OPSYS == RT_OPSYS_NETWARE
     478# ifndef RT_OS_NETWARE
     479#  define RT_OS_NETWARE
     480# endif
     481#elif RT_OPSYS == RT_OPSYS_NT
     482# ifndef RT_OS_NT
     483#  define RT_OS_NT
     484# endif
     485#elif RT_OPSYS == RT_OPSYS_OPENBSD
     486# ifndef RT_OS_OPENBSD
     487#  define RT_OS_OPENBSD
     488# endif
     489#elif RT_OPSYS == RT_OPSYS_OS2
     490# ifndef RT_OS_OS2
     491#  define RT_OS_OS2
     492# endif
     493#elif RT_OPSYS == RT_OPSYS_PLAN9
     494# ifndef RT_OS_PLAN9
     495#  define RT_OS_PLAN9
     496# endif
     497#elif RT_OPSYS == RT_OPSYS_QNX
     498# ifndef RT_OS_QNX
     499#  define RT_OS_QNX
     500# endif
     501#elif RT_OPSYS == RT_OPSYS_SOLARIS
     502# ifndef RT_OS_SOLARIS
     503#  define RT_OS_SOLARIS
     504# endif
     505#elif RT_OPSYS == RT_OPSYS_UEFI
     506# ifndef RT_OS_UEFI
     507#  define RT_OS_UEFI
     508# endif
     509#elif RT_OPSYS == RT_OPSYS_WINDOWS
     510# ifndef RT_OS_WINDOWS
     511#  define RT_OS_WINDOWS
     512# endif
     513#else
     514# error "Bad RT_OPSYS value."
     515#endif
     516
     517
     518/**
     519 * Checks whether the given OpSys uses DOS-style paths or not.
     520 *
     521 * By DOS-style paths we include drive lettering and UNC paths.
     522 *
     523 * @returns true / false
     524 * @param   a_OpSys     The RT_OPSYS_XXX value to check, will be reference
     525 *                      multiple times.
     526 */
     527#define RT_OPSYS_USES_DOS_PATHS(a_OpSys) \
     528    (   (a_OpSys) == RT_OPSYS_WINDOWS \
     529     || (a_OpSys) == RT_OPSYS_OS2 \
     530     || (a_OpSys) == RT_OPSYS_DOS )
     531
    284532
    285533
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette