diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2001-02-27 13:38:15 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2001-02-27 13:38:15 +0000 |
commit | 63a21ddc87d86190c8a4f69f7b4e6e038868b127 (patch) | |
tree | ede3618083f1d408ebd6991d05b82764a1fdf858 /sal/osl/unx/util.c | |
parent | ccdf71c514182770966cc7bda1bccb1d83bd672f (diff) |
initializes sparc architecture to V9 if available
Diffstat (limited to 'sal/osl/unx/util.c')
-rw-r--r-- | sal/osl/unx/util.c | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/sal/osl/unx/util.c b/sal/osl/unx/util.c index 8142237dfe23..5c3fe443a1c8 100644 --- a/sal/osl/unx/util.c +++ b/sal/osl/unx/util.c @@ -2,9 +2,9 @@ * * $RCSfile: util.c,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 15:17:21 $ + * last change: $Author: hr $ $Date: 2001-02-27 14:38:15 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -320,4 +320,51 @@ static char* osl_decodeEtherAddr(const char *ptr, char* buff) return(buff); } +#if defined ( SOLARIS ) && defined ( SPARC ) +#include <sys/types.h> +#include <sys/processor.h> + +/*****************************************************************************/ +/* osl_InitSparcV9 */ +/*****************************************************************************/ + +void osl_InterlockedCountSetV9(sal_Bool bV9); + +/* + * osl_InitSparcV9() should be executed as early as possible. We place it in the + * .init section of sal + */ +#if defined ( __SUNPRO_C ) || defined ( __SUNPRO_CC ) +void osl_InitSparcV9(void); +#pragma init (osl_InitSparcV9) +#elif defined ( __GNUC__ ) +void osl_InitSparcV9(void) __attribute__((constructor)); +#endif + +void osl_InitSparcV9(void) +{ + /* processor_info() identifies SPARCV8 (ie sun4c machines) simply as "sparc" + * and SPARCV9 (ie ultra sparcs, sun4u) as "sparcv9". Since we know that we + * run at least on a SPARCV8 architecture or better, any processor type != "sparc" + * and != "i386" is considered to be SPARCV9 or better + * + * This way we are certain that this will still work if someone names SPARCV10 + * "foobar" + */ + processor_info_t aInfo; + int rc; + + rc = processor_info(0, &aInfo); + + if ( rc != -1 ) { + if ( !strcmp( "sparc", aInfo.pi_processor_type ) /* SPARCV8 */ + || !strcmp( "i386", aInfo.pi_processor_type ) ) /* can't happen, but ... */ + return; + /* we are reasonably certain to be on sparcv9/sparcv8plus or better */ + osl_InterlockedCountSetV9(sal_True); + } +} + +#endif + |