1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the QtCore module of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:LGPL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
17
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
40
****************************************************************************/
46
#include "qplatformdefs.h"
47
#include "qfunctions_vxworks.h"
50
#include <selectLib.h>
59
// no lfind() - used by the TIF image format
60
void *lfind(const void* key, const void* base, size_t* elements, size_t size,
61
int (*compare)(const void*, const void*))
63
const char* current = (char*) base;
64
const char* const end = (char*) (current + (*elements) * size);
65
while (current != end) {
66
if (compare(current, key) == 0)
67
return (void*)current;
74
// no rand_r(), but rand()
75
// NOTE: this implementation is wrong for multi threaded applications,
76
// but there is no way to get it right on VxWorks (in kernel mode)
77
int rand_r(unsigned int * /*seedp*/)
82
// no usleep() support
83
int usleep(unsigned int usec)
85
div_t dt = div(usec, 1000000);
86
struct timespec ts = { dt.quot, dt.rem * 1000 };
88
return nanosleep(&ts, 0);
92
// gettimeofday() is declared, but is missing from the library
93
// It IS however defined in the Curtis-Wright X11 libraries, so
94
// we have to make the symbol 'weak'
95
#if defined(Q_CC_DIAB)
96
# pragma weak gettimeofday
98
int gettimeofday(struct timeval *tv, void /*struct timezone*/ *)
100
// the compiler will optimize this and will only use one code path
101
if (sizeof(struct timeval) == sizeof(struct timespec)) {
102
int res = clock_gettime(CLOCK_REALTIME, (struct timespec *) tv);
109
int res = clock_gettime(CLOCK_REALTIME, &ts);
111
tv->tv_sec = ts.tv_sec;
112
tv->tv_usec = ts.tv_nsec / 1000;
118
// neither getpagesize() or sysconf(_SC_PAGESIZE) are available
121
return vmPageSizeGet();
124
// symlinks are not supported (lstat is now just a call to stat - see qplatformdefs.h)
125
int symlink(const char *, const char *)
131
ssize_t readlink(const char *, char *, size_t)
137
// there's no truncate(), but ftruncate() support...
138
int truncate(const char *path, off_t length)
140
int fd = open(path, O_WRONLY, 00777);
142
int res = ftruncate(fd, length);
148
// errno is already set by open
154
// VxWorks doesn't know about passwd & friends.
155
// in order to avoid patching the unix fs path everywhere
156
// we introduce some dummy functions that simulate a single
157
// 'root' user on the system.
174
struct passwd *getpwuid(uid_t uid)
176
static struct passwd pwbuf = { "root", 0, 0, 0, 0, 0, 0 };
186
struct group *getgrgid(gid_t gid)
188
static struct group grbuf = { "root", 0, 0, 0 };
202
#endif // Q_OS_VXWORKS