1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <sal/config.h>
21 #include <sys/utsname.h>
22 
23 #if defined(LINUX)
24 #  include <stdio.h>
25 #endif
26 
27 #include <config_features.h>
28 #if HAVE_FEATURE_OPENGL
29 #include <vcl/opengl/OpenGLContext.hxx>
30 #endif
31 #include <unx/geninst.h>
32 
33 // SalYieldMutex
34 
SalYieldMutex()35 SalYieldMutex::SalYieldMutex()
36 {
37 #if HAVE_FEATURE_OPENGL
38     SetBeforeReleaseHandler( &OpenGLContext::prepareForYield );
39 #endif
40 }
41 
~SalYieldMutex()42 SalYieldMutex::~SalYieldMutex()
43 {
44 }
45 
~SalGenericInstance()46 SalGenericInstance::~SalGenericInstance()
47 {
48 }
49 
getOSVersion()50 OUString SalGenericInstance::getOSVersion()
51 {
52     struct utsname stName;
53     OUString no_uname = "unknown";
54 
55     if ( uname( &stName ) != 0 )
56         return no_uname;
57 
58     sal_Int32 nDots = 0;
59     sal_Int32 nIndex = 0;
60     OUString aVers = OUString::createFromAscii( stName.release );
61     while ( nIndex++ < aVers.getLength() )
62     {
63         const char c = stName.release[ nIndex ];
64         if ( c == ' ' || c == '-' || ( c == '.' && nDots++ > 0 ) )
65             break;
66     }
67     return OUString::createFromAscii( stName.sysname ) + " " +
68         aVers.copy( 0, nIndex );
69 }
70 
71 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
72