[ovs-dev] [PATCH 07/15] datapath-windows: Replace Types.h

Samuel Ghinet sghinet at cloudbasesolutions.com
Wed Aug 6 16:11:48 UTC 2014


Replace Types.h

The coding style on windows kernel is to use uppercase for all types. This also applies to builtin types.
We shouldn't use int64_t, uint64_t, etc. Instead, we should use windows style builtin types: INT64, UINT64, etc.

Also, the new Types.h adds macros for splitting & uniting data of variables of builtin types.

Signed-off-by: Samuel Ghinet <sghinet at cloudbasesolutions.com>
---
 datapath-windows/ovsext/Core/Types.h | 82 ++++++++++++++++++++++--------------
 1 file changed, 51 insertions(+), 31 deletions(-)

diff --git a/datapath-windows/ovsext/Core/Types.h b/datapath-windows/ovsext/Core/Types.h
index 402c39f..6527a50 100644
--- a/datapath-windows/ovsext/Core/Types.h
+++ b/datapath-windows/ovsext/Core/Types.h
@@ -1,32 +1,52 @@
 /*
- * Copyright (c) 2014 VMware, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __OVS_TYPES_H_
-#define __OVS_TYPES_H_ 1
-
-typedef unsigned long long uint64, uint64_t, ovs_be64, u64;
-typedef long long int64, int64_t;
-typedef unsigned int uint32, uint32_t, ovs_be32, u32;
-typedef unsigned short uint16, uint16_t, ovs_be16, u16;
-typedef unsigned char uint8, uint8_t, u8;
-typedef uint64 __u64, __be64;
-typedef uint32 __u32, __be32;
-typedef uint16 __u16, __be16;
-typedef uint8 __u8;
-
-#define ETH_ALEN 6
-
-#endif /* __OVS_TYPES_H_ */
+Copyright 2014 Cloudbase Solutions Srl
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http ://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+#pragma once
+
+#include "precomp.h"
+
+typedef UINT16    LE16;
+typedef UINT32    LE32;
+typedef UINT64    LE64;
+
+typedef UINT16    BE16;
+typedef UINT32    BE32;
+typedef UINT64    BE64;
+typedef UINT64    QWORD;
+
+//byte
+#define OVS_LONIBBLE(b)         ((BYTE)(((DWORD_PTR)(b)) & 0xf))
+#define OVS_HINIBBLE(b)         ((BYTE)((((DWORD_PTR)(b)) >> 4) & 0xf))
+
+#define OVS_MAKEBYTE(l, h)      ((BYTE)(OVS_LONIBBLE(l) | ((BYTE)OVS_LONIBBLE(h)) << 4))
+
+//word
+#define OVS_LOBYTE(w)           ((BYTE)(((DWORD_PTR)(w)) & 0xff))
+#define OVS_HIBYTE(w)           ((BYTE)((((DWORD_PTR)(w)) >> 8) & 0xff))
+
+#define OVS_MAKEWORD(l, h)      ((WORD)(OVS_LOBYTE(l) | ((WORD)OVS_LOBYTE(h)) << 8))
+
+//dword
+#define OVS_LOWORD(dw)          ((WORD)(((DWORD_PTR)(dw)) & 0xffff))
+#define OVS_HIWORD(dw)          ((WORD)((((DWORD_PTR)(dw)) >> 16) & 0xffff))
+
+#define OVS_MAKEDWORD(l, h)     ((DWORD)(OVS_LOWORD(l) | ((DWORD)OVS_LOWORD(h)) << 16))
+
+//qword
+#define OVS_LODWORD(qw)         ((DWORD)(((DWORD_PTR)(qw)) & 0xffffffff))
+#define OVS_HIDWORD(qw)         ((DWORD)((((DWORD_PTR)(qw)) >> 32) & 0xffffffff))
+
+#define OVS_MAKEQWORD(l, h)     ((QWORD)(OVS_LODWORD(l) | ((QWORD)OVS_LODWORD(h)) << 32))
--
1.8.3.msysgit.0





More information about the dev mailing list