1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
25 #if defined(__FreeBSD__)
26 # include <sys/utsname.h>
29 #include <config_features.h>
30 #if HAVE_FEATURE_OPENGL
31 #include <vcl/opengl/OpenGLContext.hxx>
33 #include <unx/geninst.h>
37 SalYieldMutex::SalYieldMutex()
39 #if HAVE_FEATURE_OPENGL
40 SetBeforeReleaseHandler( &OpenGLContext::prepareForYield
);
44 SalYieldMutex::~SalYieldMutex()
48 SalGenericInstance::~SalGenericInstance()
52 OUString
SalGenericInstance::getOSVersion()
54 OUString aKernelVer
= "unknown";
57 FILE* pVersion
= fopen( "/proc/version", "r" );
61 if ( fgets ( aVerBuffer
, 511, pVersion
) )
63 aKernelVer
= OUString::createFromAscii( aVerBuffer
);
64 // "Linux version 3.16.7-29-desktop ..."
65 OUString aVers
= aKernelVer
.getToken( 2, ' ' );
66 // "3.16.7-29-desktop ..."
67 sal_Int32 nTooDetailed
= aVers
.indexOf( '.', 2);
68 if (nTooDetailed
< 1 || nTooDetailed
> 8)
69 aKernelVer
= "Linux (misparsed version)";
70 else // "3.16.7-29-desktop ..."
71 aKernelVer
= OUString::Concat("Linux ") + aVers
.subView(0, nTooDetailed
);
76 #elif defined(__FreeBSD__)
77 struct utsname stName
;
78 if ( uname( &stName
) != 0 )
83 aKernelVer
= OUString::createFromAscii( stName
.release
);
84 while ( nIndex
++ < aKernelVer
.getLength() )
86 const char c
= stName
.release
[ nIndex
];
87 if ( c
== ' ' || c
== '-' || ( c
== '.' && nDots
++ > 0 ) )
90 return OUString::createFromAscii( stName
.sysname
) + " " +
91 aKernelVer
.copy( 0, nIndex
);
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */