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>
34 #include <o3tl/string_view.hxx>
38 SalYieldMutex::SalYieldMutex()
40 #if HAVE_FEATURE_OPENGL
41 SetBeforeReleaseHandler( &OpenGLContext::prepareForYield
);
45 SalYieldMutex::~SalYieldMutex()
49 SalGenericInstance::~SalGenericInstance()
53 OUString
SalGenericInstance::getOSVersion()
55 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 std::u16string_view aVers
= o3tl::getToken(aKernelVer
, 2, ' ' );
66 // "3.16.7-29-desktop ..."
67 size_t nTooDetailed
= aVers
.find( '.', 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
.substr(0, nTooDetailed
);
75 #elif defined(__FreeBSD__)
76 struct utsname stName
;
77 if ( uname( &stName
) != 0 )
82 aKernelVer
= OUString::createFromAscii( stName
.release
);
83 while ( nIndex
++ < aKernelVer
.getLength() )
85 const char c
= stName
.release
[ nIndex
];
86 if ( c
== ' ' || c
== '-' || ( c
== '.' && nDots
++ > 0 ) )
89 aKernelVer
= OUString::createFromAscii(stName
.sysname
) + " " + aKernelVer
.copy(0, nIndex
);
90 #elif defined(EMSCRIPTEN)
92 #define xstr(s) str(s)
93 aKernelVer
= "Emscripten " xstr(__EMSCRIPTEN_major__
)
94 "." xstr(__EMSCRIPTEN_minor__
) "." xstr(__EMSCRIPTEN_tiny__
);
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */