summaryrefslogtreecommitdiffstats
path: root/win/asm
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /win/asm
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'win/asm')
-rw-r--r--win/asm/byteorder.h120
-rw-r--r--win/asm/socket.h78
2 files changed, 198 insertions, 0 deletions
diff --git a/win/asm/byteorder.h b/win/asm/byteorder.h
new file mode 100644
index 000000000..d828465c4
--- /dev/null
+++ b/win/asm/byteorder.h
@@ -0,0 +1,120 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _BYTEORDER_H
+#define _BYTEORDER_H
+
+#undef INCL_WINSOCK_API_PROTOTYPES
+#define INCL_WINSOCK_API_PROTOTYPES 1 //for ntohl(), etc.
+#include <winsock2.h> //struct timeval, ntohl(), etc
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if 0
+#undef ntohl
+#undef ntohs
+#undef htonl
+#undef htons
+#endif
+
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN 1234
+#endif
+
+#ifndef __LITTLE_ENDIAN_BITFIELD
+#define __LITTLE_ENDIAN_BITFIELD
+#endif
+
+#if 1
+//defined in winsock: extern unsigned long int ntohl(unsigned long int);
+//defined in winsock: extern unsigned short int ntohs(unsigned short int);
+//defined in winsock: extern unsigned long int htonl(unsigned long int);
+//defined in winsock: extern unsigned short int htons(unsigned short int);
+
+/*
+extern __inline__ unsigned long int __ntohl(unsigned long int);
+extern __inline__ unsigned short int __ntohs(unsigned short int);
+extern __inline__ unsigned long int __constant_ntohl(unsigned long int);
+extern __inline__ unsigned short int __constant_ntohs(unsigned short int);
+*/
+
+/*
+extern __inline__ unsigned long int
+__ntohl(unsigned long int x)
+{
+ __asm__("xchgb %b0,%h0\n\t" // swap lower bytes
+ "rorl $16,%0\n\t" // swap words
+ "xchgb %b0,%h0" // swap higher bytes
+ :"=q" (x)
+ : "0" (x));
+ return x;
+}
+*/
+
+#define __constant_ntohl(x) \
+ ((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \
+ (((unsigned long int)(x) & 0x0000ff00U) << 8) | \
+ (((unsigned long int)(x) & 0x00ff0000U) >> 8) | \
+ (((unsigned long int)(x) & 0xff000000U) >> 24)))
+/*
+extern __inline__ unsigned short int
+__ntohs(unsigned short int x)
+{
+ __asm__("xchgb %b0,%h0" // swap bytes
+ : "=q" (x)
+ : "0" (x));
+ return x;
+}
+*/
+#define __constant_ntohs(x) \
+ ((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \
+ (((unsigned short int)(x) & 0xff00) >> 8))) \
+
+#define __htonl(x) __ntohl(x)
+#define __htons(x) __ntohs(x)
+#define __constant_htonl(x) __constant_ntohl(x)
+#define __constant_htons(x) __constant_ntohs(x)
+
+#ifdef __OPTIMIZE__
+# define ntohl(x) \
+(__builtin_constant_p((long)(x)) ? \
+ __constant_ntohl((x)) : \
+ __ntohl((x)))
+# define ntohs(x) \
+(__builtin_constant_p((short)(x)) ? \
+ __constant_ntohs((x)) : \
+ __ntohs((x)))
+# define htonl(x) \
+(__builtin_constant_p((long)(x)) ? \
+ __constant_htonl((x)) : \
+ __htonl((x)))
+# define htons(x) \
+(__builtin_constant_p((short)(x)) ? \
+ __constant_htons((x)) : \
+ __htons((x)))
+#endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/win/asm/socket.h b/win/asm/socket.h
new file mode 100644
index 000000000..3cf450044
--- /dev/null
+++ b/win/asm/socket.h
@@ -0,0 +1,78 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _ASM_SOCKET_H
+#define _ASM_SOCKET_H
+
+#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
+#define IOC_VOID 0x20000000 /* no parameters */
+#define IOC_OUT 0x40000000 /* copy out parameters */
+#define IOC_IN 0x80000000 /* copy in parameters */
+
+#define _IO(x,y) (IOC_VOID|(x<<8)|y)
+#define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
+#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
+
+#define SIOCATMARK _IOR('s', 7, u_long) /* at oob mark? */
+#define FIONREAD _IOR('f', 127, u_long) /* get # bytes to read */
+#define FIONBIO 0x8004667e /* To be compatible with termiost version */
+#define REAL_FIONBIO _IOW('f', 126, u_long) /* set/clear non-blocking i/o */
+#define FIOASYNC _IOW('f', 125, u_long) /* set/clear async i/o */
+#define SIOCSHIWAT _IOW('s', 0, u_long) /* set high watermark */
+#define SIOCGHIWAT _IOR('s', 1, u_long) /* get high watermark */
+#define SIOCSLOWAT _IOW('s', 2, u_long) /* set low watermark */
+#define SIOCGLOWAT _IOR('s', 3, u_long) /* get low watermark */
+
+/* Needed for if queries */
+#define SIOCGIFCONF _IOW('s', 100, struct ifconf) /* get if list */
+#define SIOCGIFFLAGS _IOW('s', 101, struct ifreq) /* Get if flags */
+#define SIOCGIFADDR _IOW('s', 102, struct ifreq) /* Get if addr */
+#define SIOCGIFBRDADDR _IOW('s', 103, struct ifreq) /* Get if broadcastaddr */
+#define SIOCGIFNETMASK _IOW('s', 104, struct ifreq) /* Get if netmask */
+#define SIOCGIFHWADDR _IOW('s', 105, struct ifreq) /* Get hw addr */
+#define SIOCGIFMETRIC _IOW('s', 106, struct ifreq) /* get metric */
+#define SIOCGIFMTU _IOW('s', 107, struct ifreq) /* get MTU size */
+
+#define SOL_SOCKET 0xffff /* options for socket level */
+
+#define SO_DEBUG 0x0001 /* turn on debugging info recording */
+#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
+#define SO_REUSEADDR 0x0004 /* allow local address reuse */
+#define SO_KEEPALIVE 0x0008 /* keep connections alive */
+#define SO_DONTROUTE 0x0010 /* just use interface addresses */
+#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
+#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
+#define SO_LINGER 0x0080 /* linger on close if data present */
+#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
+#define SO_DONTLINGER (u_int)(~SO_LINGER)
+
+/*
+ * Additional options.
+ */
+#define SO_SNDBUF 0x1001 /* send buffer size */
+#define SO_RCVBUF 0x1002 /* receive buffer size */
+#define SO_SNDLOWAT 0x1003 /* send low-water mark */
+#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
+#define SO_SNDTIMEO 0x1005 /* send timeout */
+#define SO_RCVTIMEO 0x1006 /* receive timeout */
+#define SO_ERROR 0x1007 /* get error status and clear */
+#define SO_TYPE 0x1008 /* get socket type */
+
+#endif /* _ASM_SOCKET_H */
+