Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial structure #1

Merged
merged 22 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions inc/cxplat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*++

Copyright (c) Microsoft Corporation.
Licensed under the MIT License.

Abstract:

Platform definitions.

--*/

#ifdef CX_PLATFORM_WINKERNEL
#include "cxplat_winkernel.h"
#elif CX_PLATFORM_WINUSER
#include "cxplat_winuser.h"
#elif CX_PLATFORM_LINUX
#include "cxplat_posix.h"
#elif CX_PLATFORM_DARWIN
#include "cxplat_posix.h"
#else
#error "Unsupported Platform"
#endif
35 changes: 35 additions & 0 deletions inc/cxplat_posix.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*++

Copyright (c) Microsoft Corporation.
Licensed under the MIT License.

Abstract:

Posix platform definitions.

--*/

#ifndef CXPLAT_POSIX_H
#define CXPLAT_POSIX_H

#if defined(__cplusplus)
extern "C" {
#endif

//
// Static Analysis Interfaces
//

#if defined(__clang__)
#define CXPLAT_NO_SANITIZE(X) __attribute__((no_sanitize(X)))
#else
#define CXPLAT_NO_SANITIZE(X)
#endif

#define CXPLAT_ANALYSIS_ASSUME(X)

#if defined(__cplusplus)
}
#endif

#endif // CXPLAT_POSIX_H
45 changes: 45 additions & 0 deletions inc/cxplat_winkernel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*++

Copyright (c) Microsoft Corporation.
Licensed under the MIT License.

Abstract:

Windows kernel-mode platform definitions.

--*/

#ifndef CXPLAT_WINKERNEL_H
#define CXPLAT_WINKERNEL_H

#if defined(__cplusplus)
extern "C" {
#endif

//
// Static Analysis Interfaces
//

#define CXPLAT_NO_SANITIZE(X)

#if defined(_PREFAST_)
// _Analysis_assume_ will never result in any code generation for _exp,
// so using it will not have runtime impact, even if _exp has side effects.
#define CXPLAT_ANALYSIS_ASSUME(_exp) _Analysis_assume_(_exp)
#else // _PREFAST_
// CXPLAT_ANALYSIS_ASSUME ensures that _exp is parsed in non-analysis compile.
// On DEBUG, it's guaranteed to be parsed as part of the normal compile, but
// with non-DEBUG, use __noop to ensure _exp is parseable but without code
// generation.
#if DEBUG
#define CXPLAT_ANALYSIS_ASSUME(_exp) ((void) 0)
#else // DEBUG
#define CXPLAT_ANALYSIS_ASSUME(_exp) __noop(_exp)
#endif // DEBUG
#endif // _PREFAST_

#if defined(__cplusplus)
}
#endif

#endif // CXPLAT_WINKERNEL_H
45 changes: 45 additions & 0 deletions inc/cxplat_winuser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*++

Copyright (c) Microsoft Corporation.
Licensed under the MIT License.

Abstract:

Windows user-mode platform definitions.

--*/

#ifndef CXPLAT_WINUSER_H
#define CXPLAT_WINUSER_H

#if defined(__cplusplus)
extern "C" {
#endif

//
// Static Analysis Interfaces
//

#define CXPLAT_NO_SANITIZE(X)

#if defined(_PREFAST_)
// _Analysis_assume_ will never result in any code generation for _exp,
// so using it will not have runtime impact, even if _exp has side effects.
#define CXPLAT_ANALYSIS_ASSUME(_exp) _Analysis_assume_(_exp)
#else // _PREFAST_
// CXPLAT_ANALYSIS_ASSUME ensures that _exp is parsed in non-analysis compile.
// On DEBUG, it's guaranteed to be parsed as part of the normal compile, but
// with non-DEBUG, use __noop to ensure _exp is parseable but without code
// generation.
#if DEBUG
#define CXPLAT_ANALYSIS_ASSUME(_exp) ((void) 0)
#else // DEBUG
#define CXPLAT_ANALYSIS_ASSUME(_exp) __noop(_exp)
#endif // DEBUG
#endif // _PREFAST_

#if defined(__cplusplus)
}
#endif

#endif // CXPLAT_WINUSER_H
1 change: 1 addition & 0 deletions lib/cxplat_posix.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "cxplat_posix.h"
1 change: 1 addition & 0 deletions lib/cxplat_winkernel.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "cxplat_winkernel.h"
1 change: 1 addition & 0 deletions lib/cxplat_winuser.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "cxplat_winuser.h"