- Add DDK alignment macros and move/rename the ones in the NDK for user-mode only (since kernel-mode should use the DDK ones).

- Fix helper.h's alignment macros to protect properly and also use a faster implementation.
- Update NDK readme.

svn path=/trunk/; revision=19666
This commit is contained in:
Alex Ionescu 2005-11-27 02:55:13 +00:00
parent 9ac03e5aae
commit 54f50543c1
12 changed files with 104 additions and 32 deletions

View file

@ -70,6 +70,7 @@
/* Externals */
#include <reactos/rossym.h>
#include <reactos/buildno.h>
#include <reactos/helper.h>
/* Needed if debuging is enabled */
#include <comm.h>

View file

@ -1,6 +1,7 @@
#include <debug.h>
#include <ntifs.h>
#include <ntdddisk.h>
#include <reactos/helper.h>
#ifdef __GNUC__
#include <ndk/ntndk.h>

View file

@ -178,7 +178,7 @@ typedef enum _SYSTEM_INFORMATION_CLASS
SystemPrioritySeperation,
SystemPlugPlayBusInformation,
SystemDockInformation,
_SystemPowerInformation, // FIXME
SystemPowerInformationNative,
SystemProcessorSpeedInformation,
SystemCurrentTimeZoneInformation,
SystemLookasideInformation,
@ -988,8 +988,7 @@ typedef struct _SYSTEM_DOCK_INFORMATION
} SYSTEM_DOCK_INFORMATION, *PSYSTEM_DOCK_INFORMATION;
// Class 42
// FIXME: Conflict with WINNT.H
typedef struct __SYSTEM_POWER_INFORMATION
typedef struct _SYSTEM_POWER_INFORMATION_NATIVE
{
BOOLEAN SystemSuspendSupported;
BOOLEAN SystemHibernateSupported;
@ -1001,7 +1000,7 @@ typedef struct __SYSTEM_POWER_INFORMATION
BOOLEAN SystemAcOrDc;
BOOLEAN PowerDownDisabled;
LARGE_INTEGER SpindownDrives;
} _SYSTEM_POWER_INFORMATION, *P_SYSTEM_POWER_INFORMATION;
} SYSTEM_POWER_INFORMATION_NATIVE, *PSYSTEM_POWER_INFORMATION_NATIVE;
// Class 43
typedef struct _SYSTEM_LEGACY_DRIVER_INFORMATION

View file

@ -17,12 +17,8 @@ ________________________________________________________________________________
|rtltypes.h - PPF_ Defines don't seem to be the real names (try to find them).
|rtltypes.h - _RTL_PROCESS_BACKTRACE_INFORMATION isn't done.
|haltypes.h - Multi-Boot flags are ReactOS Only.
|extypes.h - SystemPowerInformation in SYSTEM_INFORMATION_CLASS causes conflict.
|extypes.h - _RUNDOWN_DESCRIPTOR is possibly incorrect/unofficial.
|asm.h - Selector names are not official.
|extypes.h - Class 42 (SYSTEM_POWER_INFORMATION causes conflict).
|extypes.h - Classes 13, 20, 30, 31, 49, 51, 52, 54+ are undefined.
|ntndk.h - Incorrect rounding macro names
|_____________________________________________________________________________________
@ -113,4 +109,4 @@ subsys\smss\smss.h: #include <ndk/ntndk.h>
subsys\system\cmd\precomp.h: #include <ndk/ntndk.h>
subsys\system\services\services.h: #include <ndk/ntndk.h>
subsys\system\taskmgr\precomp.h: #include <ndk/ntndk.h>
subsys\system\usetup\usetup.h: #include <ndk/ntndk.h>
subsys\system\usetup\usetup.h: #include <ndk/ntndk.h>

View file

@ -234,9 +234,9 @@ typedef struct _CLIENT_DIED_MSG
// Maximum total Kernel-Mode LPC Message Structure Size
//
#define LPCP_MAX_MESSAGE_SIZE \
ROUND_UP(PORT_MAXIMUM_MESSAGE_LENGTH + \
ALIGN_UP(PORT_MAXIMUM_MESSAGE_LENGTH + \
sizeof(LPCP_MESSAGE) + \
sizeof(LPCP_CONNECTION_MESSAGE), 16)
sizeof(LPCP_CONNECTION_MESSAGE), sizeof(ULONGLONG) * 2)
//
// Maximum actual LPC Message Length

View file

@ -19,14 +19,6 @@ Author:
#ifndef _NTNDK_
#define _NTNDK_
//
// FIXME: Rounding Macros
//
#define ROUNDUP(a,b) ((((a)+(b)-1)/(b))*(b))
#define ROUNDDOWN(a,b) (((a)/(b))*(b))
#define ROUND_UP ROUNDUP
#define ROUND_DOWN ROUNDDOWN
#include <stdarg.h> // C Standard Header
#include <umtypes.h> // General Definitions

View file

@ -116,6 +116,55 @@ you would like to be credited for it.
3. USAGE
3.1 TODO (COPY FROM WIKI)
3.1 ORGANIZATION
... TODO ... (COPY FROM WIKI)
* The NDK is organized in a main folder (include/ndk) with arch-specific subfolders (ex: include/ndk/i386).
* The NDK is structured by NT Subsystem Component (ex: ex, ps, rtl, etc).
* The NDK can either be included on-demand (#include <ndk/xxxxx.h>) or globally (#include <ndk/ntndk.h>).
The former is recommended to reduce compile time.
* The NDK is structured by function and type. Every Subsystem Component has an associated "xxfuncs.h" and
"xxtypes.h" header, where "xx" is the Subsystem (ex: iofuncs.h, iotypes.h)
* The NDK has a special file called "umtypes.h" which exports to User-Mode or Native-Mode Applications the
basic NT types which are present in ntdef.h. This file cannot be included since it would conflict with
winnt.h and/or windef.h. Thus, umtypes.h provides the missing types. This file is automatically included
in a User-Mode NDK project.
* The NDK also includes a file called "umfuncs.h" which exports to User-Mode or Native-Mode Applications
undocumented functions which can only be accessed from ntdll.dll.
* The NDK has another special file called "ifssupp.h", which exports to Kernel-Mode drivers a few types which
are only documented in the IFS kit, and are part of some native definitions. It will be deprecated next year
with the release of the WDK.
3.2 USING IN YOUR PROJECT
* User Mode Application requiring Native Types:
#define WIN32_NO_STATUS /* Tell Windows headers you'll use ntstatus.s from NDK */
#include <windows.h> /* Declare Windows Headers like you normally would */
#include <ntndk.h> /* Declare the NDK Headers */
* Native Mode Application:
#include <windows.h> /* Declare Windows Headers for basic types. NEEDED UNTIL NDK 1.5 */
#include <ntndk.h> /* Declare the NDK Headers */
* Kernel Mode Driver:
#include <ntddk.h> /* Declare DDK Headers like you normally would */
#include <ntndk.h> /* Declare the NDK Headers */
* You may also include only the files you need (example for User-Mode application):
#define WIN32_NO_STATUS /* Tell Windows headers you'll use ntstatus.s from NDK */
#include <windows.h> /* Declare Windows Headers like you normally would */
#include <rtlfuncs.h> /* Declare the Rtl* Functions */
3.3 CAVEATS
* winternl.h: This header, part of the PSDK, was released by Microsoft as part of one of the governmen
lawsuits against it, and documents a certain (minimal) part of the Native API and/or types. Unforunately,
Microsoft decided to hack the Native Types and to define them incorrectly, replacing real members by "reserved"
ones. As such, you 'cannot include winternl.h in any project that uses the NDK. Note however, that the NDK fully
replaces it and retains compatibility with any project that used it.
* Native programs: Native programs must include "windows.h" until the next release of the NDK (1.5). The upcoming
version will automatically detect the lack of missing types and include them. Note however that you will still need
to have the PSDK installed.

View file

@ -60,6 +60,21 @@ Author:
#endif
#endif
//
// Alignment Macros
//
#define ALIGN_DOWN(s, t) \
((ULONG)(s) & ~(sizeof(t) - 1))
#define ALIGN_UP(s, t) \
(ALIGN_DOWN(((ULONG)(s) + sizeof(t) - 1), t))
#define ALIGN_DOWN_POINTER(p, t) \
((PVOID)((ULONG_PTR)(p) & ~((ULONG_PTR)sizeof(t) - 1)))
#define ALIGN_UP_POINTER(p, t) \
(ALIGN_DOWN_POINTER(((ULONG_PTR)(p) + sizeof(t) - 1), t))
//
// Native API Return Value Macros
//

View file

@ -1,20 +1,22 @@
#ifndef _HELPER_H
#define _HELPER_H
#ifndef ROUNDUP
#define ROUNDUP(a,b) ((((a)+(b)-1)/(b))*(b))
#endif
#ifndef ROUNDUP
#define ROUNDDOWN(a,b) (((a)/(b))*(b))
#endif
#ifndef ROUND_UP
#define ROUND_UP ROUNDUP
#define ROUND_UP(n, align) \
ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
#endif
#ifndef ROUND_DOWN
#define ROUND_DOWN ROUNDDOWN
#define ROUND_DOWN(n, align) \
(((ULONG)n) & ~((align) - 1l))
#endif
#ifndef ROUNDUP
#define ROUNDUP ROUND_UP
#endif
#ifndef ROUNDDOWN
#define ROUNDDOWN ROUND_DOWN
#endif
#ifndef PAGE_ROUND_DOWN

View file

@ -16,10 +16,11 @@
#include <math.h>
#include <limits.h>
/* PSDK/NDK Headers */
#define WIN32_NO_STATUS
#include <windows.h>
#define NTOS_MODE_USER
#include <ndk/ntndk.h>
#include <reactos/helper.h>
#if !defined(_MSC_VER)
#include <stdint.h>

View file

@ -23,6 +23,7 @@
#include <ndk/ntndk.h>
/* Internal RTL header */
#include <reactos/helper.h>
#include "rtlp.h"
/* EOF */

View file

@ -97,6 +97,21 @@ extern "C" {
#endif
#endif
/*
* Alignment Macros
*/
#define ALIGN_DOWN(s, t) \
((ULONG)(s) & ~(sizeof(t) - 1))
#define ALIGN_UP(s, t) \
(ALIGN_DOWN(((ULONG)(s) + sizeof(t) - 1), t))
#define ALIGN_DOWN_POINTER(p, t) \
((PVOID)((ULONG_PTR)(p) & ~((ULONG_PTR)sizeof(t) - 1)))
#define ALIGN_UP_POINTER(p, t) \
(ALIGN_DOWN_POINTER(((ULONG_PTR)(p) + sizeof(t) - 1), t))
/*
** Forward declarations
*/