- 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. Modified: trunk/reactos/boot/freeldr/freeldr/include/freeldr.h Modified: trunk/reactos/drivers/fs/vfat/vfat.h Modified: trunk/reactos/include/ndk/extypes.h Modified: trunk/reactos/include/ndk/fixmes.txt Modified: trunk/reactos/include/ndk/lpctypes.h Modified: trunk/reactos/include/ndk/ntndk.h Modified: trunk/reactos/include/ndk/readme.txt Modified: trunk/reactos/include/ndk/umtypes.h Modified: trunk/reactos/include/reactos/helper.h Modified: trunk/reactos/lib/crt/precomp.h Modified: trunk/reactos/lib/rtl/rtl.h Modified: trunk/reactos/w32api/include/ddk/winddk.h _____
Modified: trunk/reactos/boot/freeldr/freeldr/include/freeldr.h --- trunk/reactos/boot/freeldr/freeldr/include/freeldr.h 2005-11-26 23:26:04 UTC (rev 19665) +++ trunk/reactos/boot/freeldr/freeldr/include/freeldr.h 2005-11-27 02:55:13 UTC (rev 19666) @@ -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>
_____
Modified: trunk/reactos/drivers/fs/vfat/vfat.h --- trunk/reactos/drivers/fs/vfat/vfat.h 2005-11-26 23:26:04 UTC (rev 19665) +++ trunk/reactos/drivers/fs/vfat/vfat.h 2005-11-27 02:55:13 UTC (rev 19666) @@ -1,6 +1,7 @@
#include <debug.h> #include <ntifs.h> #include <ntdddisk.h> +#include <reactos/helper.h>
#ifdef __GNUC__ #include <ndk/ntndk.h> _____
Modified: trunk/reactos/include/ndk/extypes.h --- trunk/reactos/include/ndk/extypes.h 2005-11-26 23:26:04 UTC (rev 19665) +++ trunk/reactos/include/ndk/extypes.h 2005-11-27 02:55:13 UTC (rev 19666) @@ -178,7 +178,7 @@
SystemPrioritySeperation, SystemPlugPlayBusInformation, SystemDockInformation, - _SystemPowerInformation, // FIXME + SystemPowerInformationNative, SystemProcessorSpeedInformation, SystemCurrentTimeZoneInformation, SystemLookasideInformation, @@ -988,8 +988,7 @@ } 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 @@ 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 _____
Modified: trunk/reactos/include/ndk/fixmes.txt --- trunk/reactos/include/ndk/fixmes.txt 2005-11-26 23:26:04 UTC (rev 19665) +++ trunk/reactos/include/ndk/fixmes.txt 2005-11-27 02:55:13 UTC (rev 19666) @@ -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\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> \ No newline at end of file +subsys\system\usetup\usetup.h: #include <ndk/ntndk.h> _____
Modified: trunk/reactos/include/ndk/lpctypes.h --- trunk/reactos/include/ndk/lpctypes.h 2005-11-26 23:26:04 UTC (rev 19665) +++ trunk/reactos/include/ndk/lpctypes.h 2005-11-27 02:55:13 UTC (rev 19666) @@ -234,9 +234,9 @@
// 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 _____
Modified: trunk/reactos/include/ndk/ntndk.h --- trunk/reactos/include/ndk/ntndk.h 2005-11-26 23:26:04 UTC (rev 19665) +++ trunk/reactos/include/ndk/ntndk.h 2005-11-27 02:55:13 UTC (rev 19666) @@ -19,14 +19,6 @@
#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
_____
Modified: trunk/reactos/include/ndk/readme.txt --- trunk/reactos/include/ndk/readme.txt 2005-11-26 23:26:04 UTC (rev 19665) +++ trunk/reactos/include/ndk/readme.txt 2005-11-27 02:55:13 UTC (rev 19666) @@ -116,6 +116,55 @@
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. _____
Modified: trunk/reactos/include/ndk/umtypes.h --- trunk/reactos/include/ndk/umtypes.h 2005-11-26 23:26:04 UTC (rev 19665) +++ trunk/reactos/include/ndk/umtypes.h 2005-11-27 02:55:13 UTC (rev 19666) @@ -61,6 +61,21 @@
#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 // #define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0) _____
Modified: trunk/reactos/include/reactos/helper.h --- trunk/reactos/include/reactos/helper.h 2005-11-26 23:26:04 UTC (rev 19665) +++ trunk/reactos/include/reactos/helper.h 2005-11-27 02:55:13 UTC (rev 19666) @@ -1,20 +1,22 @@
#ifndef _HELPER_H #define _HELPER_H
-#ifndef ROUNDUP -#define ROUNDUP(a,b) ((((a)+(b)-1)/(b))*(b)) +#ifndef ROUND_UP +#define ROUND_UP(n, align) \ + ROUND_DOWN(((ULONG)n) + (align) - 1, (align)) #endif
-#ifndef ROUNDUP -#define ROUNDDOWN(a,b) (((a)/(b))*(b)) +#ifndef ROUND_DOWN +#define ROUND_DOWN(n, align) \ + (((ULONG)n) & ~((align) - 1l)) #endif
-#ifndef ROUND_UP -#define ROUND_UP ROUNDUP +#ifndef ROUNDUP +#define ROUNDUP ROUND_UP #endif
-#ifndef ROUND_DOWN -#define ROUND_DOWN ROUNDDOWN +#ifndef ROUNDDOWN +#define ROUNDDOWN ROUND_DOWN #endif
#ifndef PAGE_ROUND_DOWN _____
Modified: trunk/reactos/lib/crt/precomp.h --- trunk/reactos/lib/crt/precomp.h 2005-11-26 23:26:04 UTC (rev 19665) +++ trunk/reactos/lib/crt/precomp.h 2005-11-27 02:55:13 UTC (rev 19666) @@ -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> _____
Modified: trunk/reactos/lib/rtl/rtl.h --- trunk/reactos/lib/rtl/rtl.h 2005-11-26 23:26:04 UTC (rev 19665) +++ trunk/reactos/lib/rtl/rtl.h 2005-11-27 02:55:13 UTC (rev 19666) @@ -23,6 +23,7 @@
#include <ndk/ntndk.h>
/* Internal RTL header */ +#include <reactos/helper.h> #include "rtlp.h"
/* EOF */ _____
Modified: trunk/reactos/w32api/include/ddk/winddk.h --- trunk/reactos/w32api/include/ddk/winddk.h 2005-11-26 23:26:04 UTC (rev 19665) +++ trunk/reactos/w32api/include/ddk/winddk.h 2005-11-27 02:55:13 UTC (rev 19666) @@ -98,6 +98,21 @@
#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 */