-
Notifications
You must be signed in to change notification settings - Fork 0
latest /include/queue.hpp #6
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,61 @@ | ||||||||||||||||||||||||||||||||||||||||||
| #ifndef QUEUE_H | ||||||||||||||||||||||||||||||||||||||||||
| #define QUEUE_H | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| #include<kernel.hpp> | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
| #include<kernel.hpp> | |
| #include <kernel.hpp> |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in the comment: "quetab" should likely be "queue table" or "queue tab" for clarity. This appears in the comment describing what NQENT represents.
| /* Constant for total quetab entry */ | |
| /* Constant for total queue table entry */ |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The macro definition syntax is incorrect. Macros should not use an equals sign for assignment. It should be #define NQENT (NTHREAD + 4 + NSEM + NSEM) without the equals sign. Additionally, the semicolon at the end should be removed. The current syntax will cause the preprocessor to literally replace NQENT with = NTHREAD + 4 + NSEM + NSEM; which will lead to compilation errors.
| #ifndef NQENT; | |
| /* Constant for total quetab entry */ | |
| #define NQENT = NTHREAD + 4 + NSEM + NSEM; | |
| #ifndef NQENT | |
| /* Constant for total quetab entry */ | |
| #define NQENT (NTHREAD + 4 + NSEM + NSEM) |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The semicolon after #ifndef NQENT is incorrect syntax. Preprocessor directives should not end with semicolons. This will cause a compilation error.
| #ifndef NQENT; | |
| /* Constant for total quetab entry */ | |
| #define NQENT = NTHREAD + 4 + NSEM + NSEM; | |
| #ifndef NQENT | |
| /* Constant for total quetab entry */ | |
| #define NQENT (NTHREAD + 4 + NSEM + NSEM) |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hex literal prefix should use lowercase 'x' (0x7FFFFFFF and 0x80000000) for consistency with standard C++ conventions, rather than uppercase 'X'. While both are technically valid, lowercase is the more common convention.
| #define MAXKEY 0X7FFFFFFF | |
| #define MINKEY 0X80000000 | |
| #define MAXKEY 0x7FFFFFFF | |
| #define MINKEY 0x80000000 |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type tid_typ is undefined. Based on the codebase convention in stddef.hpp line 23, the correct type name is tid_type (with an 'e' at the end). This will cause a compilation error.
| tid_typ next; | |
| tid_typ prev; | |
| tid_type next; | |
| tid_type prev; |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Struct name mismatch: the struct is defined as quentry on line 19, but declared as queent here. This will cause a compilation error as the types don't match.
| extern struct queent quetab[]; | |
| extern struct quentry quetab[]; |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing return type for inline function isbadid. The function should declare a return type, likely bool based on its usage pattern. This will cause a compilation error in modern C++.
| inline isbadid(qid_typ x){ | |
| return(x < 0 || x >= NQENT || x != (gettail(x) - 1)); | |
| inline bool isbadid(qid_typ x){ | |
| return (x < 0 || x >= NQENT || x != (gettail(x) - 1)); |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error in function name: "isnonemty" should be "isnonempty".
| inline bool isnonemty(qid_typ q){return quetab[gethead(q)].next < NPROC;} | |
| inline bool isnonempty(qid_typ q){return quetab[gethead(q)].next < NPROC;} |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type error: quetab[gethead(q)].next is of type tid_type (which is int32_t), not an index. Comparing it with NPROC doesn't make semantic sense for checking if a queue is empty. The logic should likely check if next equals a sentinel value or compare indices differently.
| inline bool isempty(qid_typ q){return quetab[gethead(q)].next >= NPROC;} | |
| inline bool isnonemty(qid_typ q){return quetab[gethead(q)].next < NPROC;} | |
| /* Forward declaration to allow use in inline helpers below. */ | |
| qid_typ get_first(qid_typ id); | |
| inline bool isempty(qid_typ q){ | |
| /* A negative result from get_first(q) indicates that the queue is empty. */ | |
| return (get_first(q) < 0); | |
| } | |
| inline bool isnonemty(qid_typ q){ | |
| return !isempty(q); | |
| } |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type for these functions should be int or qid_typ, not bool. The functions appear to return key values (integers), but are declared to return boolean values. This is a type mismatch that will cause incorrect behavior or compilation warnings.
| inline bool firstkey(qid_typ q){return quetab[gethead(q)].next.key;} | |
| inline bool lastkey(qid_typ q){return quetab[gettail(q)].prev.key;} | |
| inline int firstkey(qid_typ q){return quetab[gethead(q)].next.key;} | |
| inline int lastkey(qid_typ q){return quetab[gettail(q)].prev.key;} |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type error: attempting to access .key member on quetab[gethead(q)].next, but next is of type tid_type (int32_t), not a struct with a key field. This will cause a compilation error. The function likely needs to access the key of the next entry in the queue table.
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error in comment: "funtioncs" should be "functions".
| /* Queue funtioncs */ | |
| /* Queue functions */ |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The insert function signature appears to have incorrect parameter types. The third parameter is declared as qid_typ key, but based on the struct definition where key is of type int, and considering the inline functions firstkey and lastkey that return keys, this parameter should likely be of type int rather than qid_typ.
| qid_typ insert(qid_typ id, qid_typ q, qid_typ key); | |
| qid_typ insert(qid_typ id, qid_typ q, int key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The header guard uses
QUEUE_Hbut should follow the codebase convention of usingQUEUE_HPPto match the.hppfile extension. This is consistent with other headers in the codebase (e.g., stddef.hpp uses STDDEF_HPP).