Commit a2141187 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Make calligra compile on Windows

Against a plain install of the dependencies, outside the
KDE emerge environment.
parent 577a9d52
......@@ -280,6 +280,15 @@ if(KDE4_BUILD_TESTS)
add_definitions(-DCOMPILING_TESTS)
endif(KDE4_BUILD_TESTS)
# overcome some platform incompatibilities
if(WIN32)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/winquirks)
add_definitions(-D_USE_MATH_DEFINES)
add_definitions(-DNOMINMAX)
set(WIN32_PLATFORM_NET_LIBS ws2_32.lib netapi32.lib)
endif(WIN32)
###########################
############################
## Required dependencies ##
......
......@@ -46,6 +46,11 @@
#define BEZIER_FLATNESS_THRESHOLD 0.5
#include <kis_distance_information.h>
#ifdef Q_OS_WIN
#include <float.h>
#define isnan _isnan
#endif
struct KisPaintOp::Private {
Private()
: dab(0),currentScale(1.0),currentRotation(0) {
......
......@@ -32,6 +32,13 @@
#define M_SQRT_2 1.41421356237309504880
#ifdef Q_OS_WIN
// on windows we get our erf() from boost
#include <boost/math/special_functions/erf.hpp>
#define erf(x) boost::math::erf(x)
#endif
struct KisGaussCircleMaskGenerator::Private {
qreal ycoef;
qreal center, distfactor, alphafactor;
......
......@@ -33,6 +33,12 @@
#define M_SQRT_2 1.41421356237309504880
#ifdef Q_OS_WIN
// on windows we get our erf() from boost
#include <boost/math/special_functions/erf.hpp>
#define erf(x) boost::math::erf(x)
#endif
struct KisGaussRectangleMaskGenerator::Private {
qreal xfade, yfade;
qreal halfWidth, halfHeight;
......
......@@ -29,7 +29,9 @@
#include <cfloat>
#include <cmath>
#include <climits>
#ifndef Q_OS_WIN
#include <strings.h>
#endif
#include <QImage>
#include <QRect>
......@@ -68,6 +70,10 @@
// Maximum distance from a Bezier control point to the line through the start
// and end points for the curve to be considered flat.
#define BEZIER_FLATNESS_THRESHOLD 0.5
#define trunc(x) ((int)(x))
#ifndef Q_OS_WIN
#endif
struct KisPainter::Private {
KisPaintDeviceSP device;
......
......@@ -19,7 +19,7 @@
*/
#include "kis_random_sub_accessor.h"
#include <QtGlobal>
#include <KoColorSpace.h>
#include <math.h>
......@@ -49,16 +49,16 @@ void KisRandomSubAccessor::sampledOldRawData(quint8* dst)
if (hsub < 0.0) hsub = 1.0 + hsub;
double vsub = m_currentPoint.y() - y;
if (vsub < 0.0) vsub = 1.0 + vsub;
weights[0] = (int)round((1.0 - hsub) * (1.0 - vsub) * 255);
weights[0] = qRound((1.0 - hsub) * (1.0 - vsub) * 255);
m_randomAccessor->moveTo(x, y);
pixels[0] = m_randomAccessor->oldRawData();
weights[1] = (int)round((1.0 - vsub) * hsub * 255);
weights[1] = qRound((1.0 - vsub) * hsub * 255);
m_randomAccessor->moveTo(x + 1, y);
pixels[1] = m_randomAccessor->oldRawData();
weights[2] = (int)round(vsub * (1.0 - hsub) * 255);
weights[2] = qRound(vsub * (1.0 - hsub) * 255);
m_randomAccessor->moveTo(x, y + 1);
pixels[2] = m_randomAccessor->oldRawData();
weights[3] = (int)round(hsub * vsub * 255);
weights[3] = qRound(hsub * vsub * 255);
m_randomAccessor->moveTo(x + 1, y + 1);
pixels[3] = m_randomAccessor->oldRawData();
m_device->colorSpace()->mixColorsOp()->mixColors(pixels, weights, 4, dst);
......@@ -75,16 +75,16 @@ void KisRandomSubAccessor::sampledRawData(quint8* dst)
if (hsub < 0.0) hsub = 1.0 + hsub;
double vsub = m_currentPoint.y() - y;
if (vsub < 0.0) vsub = 1.0 + vsub;
weights[0] = (int)round((1.0 - hsub) * (1.0 - vsub) * 255);
weights[0] = qRound((1.0 - hsub) * (1.0 - vsub) * 255);
m_randomAccessor->moveTo(x, y);
pixels[0] = m_randomAccessor->rawData();
weights[1] = (int)round((1.0 - vsub) * hsub * 255);
weights[1] = qRound((1.0 - vsub) * hsub * 255);
m_randomAccessor->moveTo(x + 1, y);
pixels[1] = m_randomAccessor->rawData();
weights[2] = (int)round(vsub * (1.0 - hsub) * 255);
weights[2] = qRound(vsub * (1.0 - hsub) * 255);
m_randomAccessor->moveTo(x, y + 1);
pixels[2] = m_randomAccessor->rawData();
weights[3] = (int)round(hsub * vsub * 255);
weights[3] = qRound(hsub * vsub * 255);
m_randomAccessor->moveTo(x + 1, y + 1);
pixels[3] = m_randomAccessor->rawData();
m_device->colorSpace()->mixColorsOp()->mixColors(pixels, weights, 4, dst);
......
......@@ -25,6 +25,11 @@
#include "kis_rect_mask_generator.h"
#include "kis_base_mask_generator.h"
#ifdef Q_OS_WIN
#include <float.h>
#define isnan _isnan
#endif
struct KisRectangleMaskGenerator::Private {
double m_c;
double m_halfWidth, m_halfHeight;
......
......@@ -31,6 +31,7 @@
#include <kglobal.h>
#include <kcmdlineargs.h>
#include <ksplashscreen.h>
#include <ksycoca.h>
#include <KoApplication.h>
......@@ -38,11 +39,28 @@
#include "data/splash/splash_screen.xpm"
#include "ui/kis_aboutdata.h"
#include "image/brushengine/kis_paintop_registry.h>
#include <Vc/global.h>
#include <Vc/support.h>
#ifdef Q_OS_WIN
#include "stdlib.h"
#endif
static void fatalError(const QString &message) {
qCritical() << "Fatal Error:" << message;
if (QMessageBox::critical(0, "Configuration Issue",
QString("Configuration for Krita has issues.\n"
"(Details: %1)\n"
"Shall we continue anyways?").arg(message),
QMessageBox::Yes|QMessageBox::No)
== QMessageBox::No) {
qFatal("aborting due to configuration issues");
}
}
extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
{
#ifdef Q_WS_X11
......@@ -56,15 +74,64 @@ extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
KCmdLineOptions options;
options.add("+[file(s)]", ki18n("File(s) or URL(s) to open"));
options.add( "hwinfo", ki18n( "Show some information about the hardware" ));
KCmdLineArgs::addCmdLineOptions(options);
// first create the application so we can create a pixmap
KoApplication app;
if (args->isSet("hwinfo")) {
QString hwinfo;
QTextStream stst(&hwinfo);
if (Vc::isImplementationSupported(Vc::SSE2Impl)) {
stst << "Vc::SSE2Impl: " << Vc::CpuId::hasSse2() << "\n";
}
if (Vc::isImplementationSupported(Vc::SSE3Impl)) {
stst << "Vc::SSE3Impl: " << Vc::CpuId::hasSse3() << "\n";
}
if (Vc::isImplementationSupported(Vc::SSSE3Impl)) {
stst << "Vc::SSSE3Impl: " << Vc::CpuId::hasSsse3() << "\n";
}
if (Vc::isImplementationSupported(Vc::SSE41Impl)) {
stst << "Vc::SSE41Impl: " << Vc::CpuId::hasSse41() << "\n";
}
if (Vc::isImplementationSupported(Vc::SSE42Impl)) {
stst << "Vc::SSE42Impl: " << Vc::CpuId::hasSse42() << "\n";
}
if (Vc::isImplementationSupported(Vc::AVXImpl)) {
stst << "Vc::AVXImpl: " << (Vc::CpuId::hasOsxsave()
&& Vc::CpuId::hasAvx()) << "\n";
}
if (Vc::isImplementationSupported(Vc::AVX2Impl)) {
stst << "Vc::AVX2Impl: " << false << "\n";
}
QMessageBox::information(0, "hwinfo", hwinfo);
qApp->quit();
// quit() is not good enough to terminate here.
qFatal("hwinfo");
}
#ifdef Q_WS_X11
app.setAttribute(Qt::AA_X11InitThreads, true);
#endif
// assert krita.rc
QString krita_rc_check = KStandardDirs::locate("data", "krita/krita.rc");
qDebug() << "KStandardDirs::locate(data, krita.rc):" << krita_rc_check;
if (krita_rc_check.isNull() || krita_rc_check.isEmpty()) {
fatalError("rc missing");
}
KisPaintOpRegistry *reg = KisPaintOpRegistry::instance();
if (!reg) bark("KisPaintOpRegistry missing");
// we should have some paintops by now; if not - terminate gracefully
// (instead of crashing later inside kritasketch)
if (reg->listKeys().empty()) {
fatalError("paintops missing");
}
// then create the pixmap from an xpm: we cannot get the
// location of our datadir before we've started our components,
// so use an xpm.
......
......@@ -23,6 +23,7 @@
#include <klocale.h>
#include <QtGlobal>
#include <QLayout>
#include <QPixmap>
#include <QPainter>
......@@ -182,14 +183,14 @@ void KisLevelConfigWidget::slotDrawHistogram(bool logarithmic)
if (histogram->getHistogramType() == LINEAR) {
double factor = (double)(wHeight - wHeight / 5.0) / highest;
for (int i = 0; i < wWidth; i++) {
int binNo = (int)round((double)i / wWidth * (bins - 1));
int binNo = qRound((double)i / wWidth * (bins - 1));
if ((int)histogram->getValue(binNo) != 0)
p.drawLine(i, wHeightMinusOne, i, wHeightMinusOne - (int)histogram->getValue(binNo) * factor);
}
} else {
double factor = (double)(wHeight - wHeight / 5.0) / (double)log(highest);
for (int i = 0; i < wWidth; i++) {
int binNo = (int)round((double)i / wWidth * (bins - 1)) ;
int binNo = qRound((double)i / wWidth * (bins - 1)) ;
if ((int)histogram->getValue(binNo) != 0)
p.drawLine(i, wHeightMinusOne, i, wHeightMinusOne - log((double)histogram->getValue(binNo)) * factor);
}
......
......@@ -27,7 +27,12 @@ set(kritapsdimport_PART_SRCS
)
kde4_add_plugin(kritapsdimport ${kritapsdimport_PART_SRCS})
target_link_libraries(kritapsdimport kritaui )
if (WIN32)
target_link_libraries(kritapsdimport kritaui ${WIN32_PLATFORM_NET_LIBS})
else (WIN32)
target_link_libraries(kritapsdimport kritaui )
endif (WIN32)
install(TARGETS kritapsdimport DESTINATION ${PLUGIN_INSTALL_DIR})
########### next target ###############
......@@ -39,7 +44,12 @@ set(kritapsdexport_PART_SRCS
)
kde4_add_plugin(kritapsdexport ${kritapsdexport_PART_SRCS})
target_link_libraries(kritapsdexport kritaui )
if (WIN32)
target_link_libraries(kritapsdexport kritaui ${WIN32_PLATFORM_NET_LIBS})
else (WIN32)
target_link_libraries(kritapsdexport kritaui )
endif (WIN32)
install(TARGETS kritapsdexport DESTINATION ${PLUGIN_INSTALL_DIR})
install( FILES krita_psd_import.desktop
......
......@@ -16,7 +16,11 @@ kde4_add_plugin(kritaxcfimport ${kritaxcfimport_PART_SRCS})
target_link_libraries(kritaxcfimport kritaui )
install(TARGETS kritaxcfimport DESTINATION ${PLUGIN_INSTALL_DIR})
if (WIN32)
target_link_libraries(kritaxcfimport kritaui ${WIN32_PLATFORM_NET_LIBS})
else (WIN32)
install(TARGETS kritaxcfimport DESTINATION ${PLUGIN_INSTALL_DIR})
endif (WIN32)
########### install files ###############
......
......@@ -21,6 +21,7 @@
#include <cmath>
#include <QtGlobal>
#include <QRect>
#include <kis_image.h>
......@@ -41,6 +42,13 @@
#include <KoColorSpaceRegistry.h>
#include <KoCompositeOp.h>
#ifdef Q_OS_WIN
// quoting DRAND48(3) man-page:
// These functions are declared obsolete by SVID 3,
// which states that rand(3) should be used instead.
#define drand48() (static_cast<double>(qrand()) / static_cast<double>(RAND_MAX))
#endif
KisDeformPaintOp::KisDeformPaintOp(const KisDeformPaintOpSettings *settings, KisPainter * painter, KisImageWSP image)
: KisPaintOp(painter)
{
......
......@@ -21,6 +21,7 @@
#include <cmath>
#include <QtGlobal>
#include <QRect>
#include <kis_global.h>
......@@ -42,6 +43,13 @@
#include <QTime>
#endif
#ifdef Q_OS_WIN
// quoting DRAND48(3) man-page:
// These functions are declared obsolete by SVID 3,
// which states that rand(3) should be used instead.
#define drand48() (static_cast<double>(qrand()) / static_cast<double>(RAND_MAX))
#endif
KisGridPaintOp::KisGridPaintOp(const KisGridPaintOpSettings *settings, KisPainter * painter, KisImageWSP image)
: KisPaintOp( painter )
, m_settings( settings )
......
......@@ -19,6 +19,14 @@
#include "random_gauss.h"
#include <cmath>
#include <QtGlobal>
#ifdef Q_OS_WIN
// quoting DRAND48(3) man-page:
// These functions are declared obsolete by SVID 3,
// which states that rand(3) should be used instead.
#define drand48() (static_cast<double>(qrand()) / static_cast<double>(RAND_MAX))
#endif
double RandomGauss::nextGaussian(double mean, double sigma){
if (m_next)
{
......
......@@ -19,10 +19,14 @@
#include "gauss.h"
#include <math.h>
#include <stdlib.h>
#include <QtGlobal>
#if defined(_WIN32) || defined(_WIN64)
#ifdef Q_OS_WIN
// quoting DRAND48(3) man-page:
// These functions are declared obsolete by SVID 3,
// which states that rand(3) should be used instead.
#define srand48 srand
#define drand48() (static_cast<double>(qrand()) / static_cast<double>(RAND_MAX))
#endif
double gauss::gaussian(double mean, double std, int seed)
......
......@@ -34,7 +34,11 @@ if(HAVE_VC)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Vc_DEFINITIONS}")
endif(HAVE_VC)
if (WIN32)
target_link_libraries(kritalibbrush LINK_INTERFACE_LIBRARIES kritaui ${WIN32_PLATFORM_NET_LIBS})
else (WIN32)
target_link_libraries(kritalibbrush LINK_INTERFACE_LIBRARIES kritaui)
endif (WIN32)
set_target_properties(kritalibbrush PROPERTIES
VERSION ${GENERIC_CALLIGRA_LIB_VERSION} SOVERSION ${GENERIC_CALLIGRA_LIB_SOVERSION}
......
......@@ -28,6 +28,15 @@
#include <KoColor.h>
#include <KoColorSpace.h>
#include <QtGlobal>
#ifdef Q_OS_WIN
// quoting DRAND48(3) man-page:
// These functions are declared obsolete by SVID 3,
// which states that rand(3) should be used instead.
#define drand48() (static_cast<double>(qrand()) / static_cast<double>(RAND_MAX))
#endif
KisPressureScatterOption::KisPressureScatterOption()
: KisCurveOption(i18n("Scatter"), "Scatter", KisPaintOpOption::brushCategory(), false, 1.0, 0.0, 5.0)
{
......
......@@ -40,6 +40,15 @@
#include <kis_pressure_opacity_option.h>
#include <kis_dab_cache.h>
#include <QtGlobal>
#ifdef Q_OS_WIN
// quoting DRAND48(3) man-page:
// These functions are declared obsolete by SVID 3,
// which states that rand(3) should be used instead.
#define drand48() (static_cast<double>(qrand()) / static_cast<double>(RAND_MAX))
#endif
/*
* Based on Harmony project http://github.com/mrdoob/harmony/
*/
......
......@@ -19,6 +19,14 @@
#include "random_gauss.h"
#include <cmath>
#include <QtGlobal>
#ifdef Q_OS_WIN
// quoting DRAND48(3) man-page:
// These functions are declared obsolete by SVID 3,
// which states that rand(3) should be used instead.
#define drand48() (static_cast<double>(qrand()) / static_cast<double>(RAND_MAX))
#endif
qreal RandomGauss::nextGaussian(qreal mean, qreal sigma)
{
if (m_next) {
......
......@@ -49,6 +49,15 @@
#include "random_gauss.h"
#include <QtGlobal>
#ifdef Q_OS_WIN
// quoting DRAND48(3) man-page:
// These functions are declared obsolete by SVID 3,
// which states that rand(3) should be used instead.
#define drand48() (static_cast<double>(qrand()) / static_cast<double>(RAND_MAX))
#endif
SprayBrush::SprayBrush()
{
srand48(time(0));
......
......@@ -34,6 +34,14 @@
static const int MAXIMUM_BRUSHES = 50;
#include <QtGlobal>
#ifdef Q_OS_WIN
// quoting DRAND48(3) man-page:
// These functions are declared obsolete by SVID 3,
// which states that rand(3) should be used instead.
#define drand48() (static_cast<double>(qrand()) / static_cast<double>(RAND_MAX))
#endif
KisToolMultihand::KisToolMultihand(KoCanvasBase *canvas)
: KisToolBrush(canvas),
......
......@@ -27,7 +27,7 @@
#include <cstdlib>
// Qt includes.
#include <QtGlobal>
#include <QPainter>
#include <QPoint>
#include <QPen>
......@@ -35,8 +35,6 @@
#include <QBrush>
#include <QLinearGradient>
KisGradientSlider::KisGradientSlider(QWidget *parent)
: QWidget(parent)
, m_leftmost(0)
......@@ -78,7 +76,7 @@ void KisGradientSlider::paintEvent(QPaintEvent *)
int wWidth = width();
int wHeight = height();
const int gradientHeight = (int)round((double)wHeight / 7.0 * 2);
const int gradientHeight = qRound((double)wHeight / 7.0 * 2);
QPainter p1(this);
......@@ -230,12 +228,12 @@ void KisGradientSlider::mouseReleaseEvent(QMouseEvent * e)
switch (m_grabCursor) {
case BlackCursor:
m_black = (int)round(m_blackCursor / m_scalingFactor);
m_black = qRound(m_blackCursor / m_scalingFactor);
m_feedback = true;
emit sigModifiedBlack(m_black);
break;
case WhiteCursor:
m_white = (int)round(m_whiteCursor / m_scalingFactor);
m_white = qRound(m_whiteCursor / m_scalingFactor);
m_feedback = true;
emit sigModifiedWhite(m_white);
break;
......@@ -297,8 +295,8 @@ void KisGradientSlider::mouseMoveEvent(QMouseEvent * e)
void KisGradientSlider::calculateCursorPositions()
{
m_blackCursor = (int)round(m_black * m_scalingFactor);
m_whiteCursor = (int)round(m_white * m_scalingFactor);
m_blackCursor = qRound(m_black * m_scalingFactor);
m_whiteCursor = qRound(m_white * m_scalingFactor);
m_gammaCursor = calculateGammaCursor();
}
......@@ -326,7 +324,7 @@ void KisGradientSlider::slotModifyBlack(int v)
{
if (v >= 0 && v <= (int)m_white && !m_feedback) {
m_black = v;
m_blackCursor = (int)round(m_black * m_scalingFactor);
m_blackCursor = qRound(m_black * m_scalingFactor);
m_gammaCursor = calculateGammaCursor();
update();
}
......@@ -335,7 +333,7 @@ void KisGradientSlider::slotModifyWhite(int v)
{
if (v >= (int)m_black && v <= width() && !m_feedback) {
m_white = v;
m_whiteCursor = (int)round(m_white * m_scalingFactor);
m_whiteCursor = qRound(m_white * m_scalingFactor);
m_gammaCursor = calculateGammaCursor();
update();
}
......
......@@ -25,13 +25,13 @@
#include <QToolButton>
#include <kicon.h>
#include <stdlib.h> // for random()
#include <QtGlobal> // for qrand()
// ************ ToolHelper **********
ToolHelper::ToolHelper(KoToolFactoryBase *tool)
{
m_toolFactory = tool;
m_uniqueId = (int) random();
m_uniqueId = (int) qrand();
}
QToolButton* ToolHelper::createButton()
......
......@@ -62,6 +62,7 @@
#include <kfileitem.h>
#include <kio/netaccess.h>
#include <QtGlobal>
#include <QBuffer>
#include <QDir>
#include <QFileInfo>
......@@ -1465,10 +1466,10 @@ bool KoDocument::loadNativeFormat(const QString & file_)
continue;
pos++;
} while (pos < 5);
isRawXML = (strncasecmp(buf, "<?xml", 5) == 0);
isRawXML = (qstrnicmp(buf, "<?xml", 5) == 0);
if (! isRawXML)
// also check for broken MathML files, which seem to be rather common
isRawXML = (strncasecmp(buf, "<math", 5) == 0); // file begins with <math ?
isRawXML = (qstrnicmp(buf, "<math", 5) == 0); // file begins with <math ?
//kDebug(30003) <<"PATTERN=" << buf;
}
// Is it plain XML?
......
project(pigmentcms)
# we have to repeat platform specifics from top-level
if (WIN32)
include_directories(${CMAKE_SOURCE_DIR}/winquirks)
add_definitions(-D_USE_MATH_DEFINES)
add_definitions(-DNOMINMAX)
set(WIN32_PLATFORM_NET_LIBS ws2_32.lib netapi32.lib)
endif (WIN32)
include_directories( ${PIGMENT_INCLUDES} ${QT_INCLUDES} ${Boost_INCLUDE_DIR})
set(FILE_OPENEXR_SOURCES)
......@@ -120,6 +128,7 @@ target_link_libraries(
${EXTRA_LIBRARIES}
${QT_QTGUI_LIBRARY}
${QT_QTXML_LIBRARY}
${WIN32_PLATFORM_NET_LIBS}
)
target_link_libraries(
......
......@@ -24,6 +24,11 @@
#include <kglobal.h>
#include <klocale.h>
#ifdef Q_OS_WIN
#include <float.h>
#define isnan _isnan
#endif
// #define DEBUG_VALIDATOR
// #define DEBUG_VALUEFROMTEXT
......
......@@ -69,7 +69,7 @@ QList<qreal> KoZoomAction::Private::generateSliderZoomLevels() const
{
QList<qreal> zoomLevels;
qreal defaultZoomStep = sqrt(2);
qreal defaultZoomStep = sqrt(2.0);
zoomLevels << 0.25 / 2.0;
zoomLevels << 0.25 / 1.5;
......
Without introducing some artificial compatibility layers,
a native windows development environment (e.g. Visual Studio 2010)
does not know about some includes known in the UNIX world.
For this reason the winquirks/ directory shall provide a minimal
approach to such an compatibility layer.
#ifndef QUIRK_NETINET_IN_H
#define QUIRK_NETINET_IN_H
/*
* this is used for htonl mostly.
*
* while POSIX specifies <arpa/inet.h> as the portable
* include file, <netinet/in.h> is used throughout
* calligra.
*
*/
#pragma message("winquirk: no netinet/in.h!")
#include <Winsock2.h>
#endif
#ifndef QUIRK_SYS_TIME_H
#define QUIRK_SYS_TIME_H
#include <time.h>
#include <windows.h>
#include <WinSock2.h>
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif
struct timezone
{
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
static int
gettimeofday(struct timeval * tv, struct timezone * tz)
{
FILETIME ft;
unsigned __int64 tmpres = 0;
static int tzflag;
if (NULL != tv)
{
GetSystemTimeAsFileTime(&ft);
tmpres |= ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
/*converting file time to unix epoch*/
tmpres -= DELTA_EPOCH_IN_MICROSECS;
tmpres /= 10; /*convert into microseconds*/
tv->tv_sec = (long)(tmpres / 1000000UL);
tv->tv_usec = (long)(tmpres % 1000000UL);
}
if (NULL != tz)
{
if (!tzflag)
{
_tzset();
tzflag++;
}
tz->tz_minuteswest = _timezone / 60;
tz->tz_dsttime = _daylight;
}