[system] Add centralized status and POC for hello#240
Draft
esnguyen wants to merge 1 commit intogoogle:mainfrom
Draft
[system] Add centralized status and POC for hello#240esnguyen wants to merge 1 commit intogoogle:mainfrom
esnguyen wants to merge 1 commit intogoogle:mainfrom
Conversation
We want to centralize the error status by goign with a compacted 64 bit error reporting format. This can provide context, domain, and specific error code. The hello would is used to create an example of the error code foundation. This doesnt include the utlility to convert 64 error to human readable yet Signed-off-by: Ellis Nguyen <sarzanguyen@google.com>
xorptr
reviewed
Mar 19, 2026
| typedef uint64_t libhoth_error; | ||
|
|
||
| #define LIBHOTH_ERR_CONSTRUCT(ctx, space, code) \ | ||
| (((uint64_t)(ctx) << 32) | ((uint64_t)(space) << 16) | (uint64_t)(code)) |
Collaborator
There was a problem hiding this comment.
nit: Would it be a good idea to mask (at least) space and code? or maybe add a static_assert to ensure that they are not more than 16 bits in size?
Otherwise misuse of this macro can cause confusion (since the macro does not mention what type to use for each parameter). Eg:
#include <stdint.h>
#include <stdio.h>
#define LIBHOTH_ERR_CONSTRUCT(ctx, space, code) \
(((uint64_t)(ctx) << 32) | ((uint64_t)(space) << 16) | (uint64_t)(code))
int main(void) {
printf("0x%lx\n", LIBHOTH_ERR_CONSTRUCT(0x66778899, 0xAABBCC, 0xDDEEFF));
}Output: 0x667788bbbbddeeff
Collaborator
There was a problem hiding this comment.
making this an inline function is also an option. That way the type of parameters is more clear, and the compiler can handle truncation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We want to centralize the error status by goign with a compacted 64 bit error reporting format. This can provide context, domain, and specific error code. The hello would is used to create an example of the error code foundation. This doesnt include the utlility to convert 64 error to human readable yet