win32-posix: move to kdelibs/win/
Peter Kümmel
syntheticpp at gmx.net
Sun Feb 12 18:18:48 CET 2006
Hi,
I've found several functions in kdelibs which
could be moved to kdewin32.
I've checked if they are a posix function,
http://www.unix.org/single_unix_specification/
and moved them to /win.
I've also added one test to the configure
process to find the inline function isinf.
It compiles fine with kdecore, kio, kdeiu.
Could you please have a look at it.
Peter
THE diff:
Index: ConfigureChecks.cmake
===================================================================
--- ConfigureChecks.cmake (Revision 508639)
+++ ConfigureChecks.cmake (Arbeitskopie)
@@ -281,6 +281,14 @@
check_function_exists(isinf HAVE_FUNC_ISINF)
check_function_exists(isnan HAVE_FUNC_ISNAN)
+
+
+# check for inline function
+
+check_prototype_exists(isinf math.h HAVE_INLINE_FUNC_ISINF)
+
+
+
# check for prototypes
check_prototype_exists(mkstemps "stdlib.h;unistd.h" HAVE_MKSTEMPS_PROTO)
Index: kio/kio/kurlcompletion.cpp
===================================================================
--- kio/kio/kurlcompletion.cpp (Revision 508030)
+++ kio/kio/kurlcompletion.cpp (Arbeitskopie)
@@ -757,13 +757,12 @@
// Environment variables
//
-#ifdef Q_OS_WIN
-#include <stdlib.h>
-char **environ = _environ;
-#else
+#ifndef _WIN32
+// do we really need this? Its already declared in unistd.h
extern char **environ; // Array of environment variables
#endif
+
bool KUrlCompletion::envCompletion(const MyURL &url, QString *pMatch)
{
if ( url.file().isEmpty() || url.file().at(0) != QLatin1Char('$') )
Index: win/iceauth/process.c
===================================================================
--- win/iceauth/process.c (Revision 508030)
+++ win/iceauth/process.c (Arbeitskopie)
@@ -561,9 +561,7 @@
register_signals ();
-#ifdef _WIN32
-#define bzero(a,b) memset(a,0,b)
-#endif
+
bzero ((char *) hexvalues, sizeof hexvalues);
hexvalues['0'] = 0;
hexvalues['1'] = 1;
Index: win/include/msvc/math.h
===================================================================
--- win/include/msvc/math.h (Revision 508030)
+++ win/include/msvc/math.h (Arbeitskopie)
@@ -20,6 +20,8 @@
#ifndef KDEWIN_MATH_H
#define KDEWIN_MATH_H
+#include <../include/float.h>
+
// some functions which aren't available with msvc
// float rintf( float x )
// double rint( double x )
@@ -28,6 +30,38 @@
// double nearbyint(double x)
// long double nearbyintl(long double x)
+
+# define isfinite(x) _finite(x)
+# define copysign(x, y) _copysign(x, y)
+
+__inline int isinf(double d)
+{
+ int cl = _fpclass(d);
+ return ( cl==_FPCLASS_PINF ? +1 : (cl==_FPCLASS_NINF ? -1 : 0) );
+}
+
+__inline int signbit(double d)
+{
+ // FIXME: Not sure if this is exactly right.
+ switch (_fpclass(d)) {
+ case _FPCLASS_NINF:
+ case _FPCLASS_NN:
+ case _FPCLASS_ND:
+ case _FPCLASS_NZ:
+ // It's one of wacky negatives, report as negative.
+ return 1;
+ case _FPCLASS_PINF:
+ case _FPCLASS_PN:
+ case _FPCLASS_PD:
+ case _FPCLASS_PZ:
+ // It's one of wacky positives, report as positive.
+ return 0;
+ default:
+ return d < 0;
+ }
+}
+
+
// this is easy
__inline float rintf( float x )
{
Index: win/include/msvc/strings.h
===================================================================
--- win/include/msvc/strings.h (Revision 508030)
+++ win/include/msvc/strings.h (Arbeitskopie)
@@ -17,6 +17,11 @@
Boston, MA 02110-1301, USA.
*/
-//empty for now, to avoid #ifdefs
+#ifndef KDEWIN_STRINGS_H
+#define KDEWIN_STRINGS_H
+#define bzero(a,b) memset(a,0,b)
+
+
+#endif
\ No newline at end of file
Index: win/include/msvc/time.h
===================================================================
--- win/include/msvc/time.h (Revision 508030)
+++ win/include/msvc/time.h (Arbeitskopie)
@@ -23,11 +23,7 @@
#include <winposix_export.h>
#include <../include/time.h>
-struct timezone
-{
- int tz_minuteswest;
- int tz_dsttime;
-};
+#define timezone _timezone
#ifdef __cplusplus
extern "C" {
Index: win/include/msvc/unistd.h
===================================================================
--- win/include/msvc/unistd.h (Revision 508030)
+++ win/include/msvc/unistd.h (Arbeitskopie)
@@ -64,6 +64,7 @@
#define S_ISLNK(m) (((m)&_IFMT) == _IFLNK)
#define S_ISSOCK(m) (((m)&_IFMT) == _IFSOCK)
+#define environ _environ
KDEWIN32_EXPORT int chown(const char *__path, uid_t __owner, gid_t __group);
Index: win/include/msvc/sys/time.h
===================================================================
--- win/include/msvc/sys/time.h (Revision 508030)
+++ win/include/msvc/sys/time.h (Arbeitskopie)
@@ -38,8 +38,9 @@
extern "C" {
#endif
-KDEWIN32_EXPORT int gettimeofday(struct timeval *__p, struct timezone *__z);
-KDEWIN32_EXPORT int settimeofday(const struct timeval *, const struct timezone *);
+//KDEWIN32_EXPORT int gettimeofday(struct timeval *__p, struct timezone *__z);
+KDEWIN32_EXPORT int gettimeofday(struct timeval *__p, void *__t);
+// it's not a posix function
+//KDEWIN32_EXPORT int settimeofday(const struct timeval *, const struct timezone *);
#ifdef __cplusplus
}
Index: win/src/time.c
===================================================================
--- win/src/time.c (Revision 508030)
+++ win/src/time.c (Arbeitskopie)
@@ -31,7 +31,7 @@
//
// sys/time.h fnctions
//
-KDEWIN32_EXPORT int gettimeofday(struct timeval *__p, struct timezone *__t)
+KDEWIN32_EXPORT int gettimeofday(struct timeval *__p, void *__t)
{
union {
unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */
@@ -44,7 +44,7 @@
return (0);
}
-
+#if 0
KDEWIN32_EXPORT int settimeofday(const struct timeval *__p, const struct timezone *__t)
{
union {
@@ -59,7 +59,7 @@
SetSystemTime( &st );
return 1;
}
-
+#endif
//
// time.h functions
//
Index: kdecore/ktimezones.cpp
===================================================================
--- kdecore/ktimezones.cpp (Revision 508030)
+++ kdecore/ktimezones.cpp (Arbeitskopie)
@@ -677,8 +677,8 @@
// Add entry to list.
if (tokens[0] == "??")
tokens[0] = "";
- KTimezone *timezone = new KSystemTimezone(m_source, tokens[2], tokens[0], latitude, longitude, (n > 3 ? tokens[3] : QString()));
- add(timezone);
+ KTimezone *t_zone = new KSystemTimezone(m_source, tokens[2], tokens[0], latitude, longitude, (n > 3 ? tokens[3] : QString()));
+ add(t_zone);
}
}
f.close();
Index: kdecore/kde_file.h
===================================================================
--- kdecore/kde_file.h (Revision 508030)
+++ kdecore/kde_file.h (Arbeitskopie)
@@ -103,15 +103,14 @@
#ifdef _LFS64_STDIO
-#define KDE_fopen ::fopen64
-#define KDE_freopen ::freopen64
-/* TODO: define for win32 */
-#else
+#define KDE_fopen ::fopen64
+#define KDE_freopen ::freopen64
+#else /* win32 */
#ifdef _WIN32
-#define KDE_fopen kdewin32_fopen
+#define KDE_fopen kdewin32_fopen
#define KDE_freopen kdewin32_freopen
#else /* unix */
-#define KDE_fopen ::fopen
+#define KDE_fopen ::fopen
#endif
#endif
Index: kjs/internal.cpp
===================================================================
--- kjs/internal.cpp (Revision 508030)
+++ kjs/internal.cpp (Arbeitskopie)
@@ -48,10 +48,6 @@
#include <math.h>
#include <stdio.h>
-#if defined(_WIN32) || defined(_WIN64)
-#include <float.h>
-#define copysign(a, b) _copysign(a, b)
-#endif
extern int kjsyyparse();
Index: kjs/math_object.cpp
===================================================================
--- kjs/math_object.cpp (Revision 508030)
+++ kjs/math_object.cpp (Arbeitskopie)
@@ -35,32 +35,7 @@
#include "math_object.lut.h"
-#if defined(_WIN32) || defined(_WIN64)
-#include <float.h>
-static int signbit(double d)
-{
- // FIXME: Not sure if this is exactly right.
- switch (_fpclass(d)) {
- case _FPCLASS_NINF:
- case _FPCLASS_NN:
- case _FPCLASS_ND:
- case _FPCLASS_NZ:
- // It's one of wacky negatives, report as negative.
- return 1;
- case _FPCLASS_PINF:
- case _FPCLASS_PN:
- case _FPCLASS_PD:
- case _FPCLASS_PZ:
- // It's one of wacky positives, report as positive.
- return 0;
- default:
- return d < 0;
- }
-}
-
-#endif
-
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif /* M_PI */
Index: kjs/date_object.cpp
===================================================================
--- kjs/date_object.cpp (Revision 508030)
+++ kjs/date_object.cpp (Arbeitskopie)
@@ -56,20 +56,6 @@
#include <CoreFoundation/CoreFoundation.h>
#endif
-#if defined(_WIN32) || defined(_WIN64)
-# ifndef HAVE_COPYSIGN
-# define copysign(x, y) _copysign(x, y)
-# endif
-# ifndef HAVE_ISFINITE
-# define isfinite(x) _finite(x)
-# endif
-# ifndef HAVE_STRNCASECMP
-# define strncasecmp(x, y, z) strnicmp(x, y, z)
-# endif
-# ifndef HAVE_SNPRINTF
-# define snprintf _snprintf
-# endif
-#endif
inline int gmtoffset(const tm& t)
{
Index: kjs/operations.cpp
===================================================================
--- kjs/operations.cpp (Revision 508030)
+++ kjs/operations.cpp (Arbeitskopie)
@@ -58,10 +58,7 @@
bool isInf(double d)
{
-#if defined(_WIN32) || defined(_WIN64)
- int fpClass = _fpclass(d);
- return _FPCLASS_PINF == fpClass || _FPCLASS_NINF == fpClass;
-#elif defined(HAVE_FUNC_ISINF)
+#if defined(HAVE_FUNC_ISINF)
return isinf(d);
#elif HAVE_FUNC_FINITE
return finite(d) == 0 && d == d;
@@ -74,9 +71,7 @@
bool isPosInf(double d)
{
-#if defined(_WIN32) || defined(_WIN64)
- return _FPCLASS_PINF == _fpclass(d);
-#elif defined(HAVE_FUNC_ISINF)
+#if defined(HAVE_FUNC_ISINF)
return (isinf(d) == 1);
#elif HAVE_FUNC_FINITE
return finite(d) == 0 && d == d; // ### can we distinguish between + and - ?
@@ -89,9 +84,7 @@
bool isNegInf(double d)
{
-#if defined(_WIN32) || defined(_WIN64)
- return _FPCLASS_PINF == _fpclass(d);
-#elif defined(HAVE_FUNC_ISINF)
+#if defined(HAVE_FUNC_ISINF)
return (isinf(d) == -1);
#elif HAVE_FUNC_FINITE
return finite(d) == 0 && d == d; // ###
Index: config.h.cmake
===================================================================
--- config.h.cmake (Revision 508030)
+++ config.h.cmake (Arbeitskopie)
@@ -320,6 +320,11 @@
/*********************/
+#if defined(HAVE_INLINE_FUNC_ISINF)
+#define HAVE_FUNC_ISINF 1
+#endif
+
+
#if !defined(HAVE_GETHOSTNAME_PROTO)
#ifdef __cplusplus
extern "C" {
@@ -476,7 +481,6 @@
#endif
-
#ifndef HAVE_S_ISSOCK
#define HAVE_S_ISSOCK
#define S_ISSOCK(mode) (1==0)
More information about the Kde-buildsystem
mailing list