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

changed integer types to their correct enum types #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

verpeteren
Copy link
Contributor

In a few locations integer typed variables where used where their corresponding enum would be a better choice.

In a few locations integer typed variables where used where their corresponding enum would be a better choice.
The ape_socket.states struct had origially 4 uint8_t fields. That fits nice in memory. By changing this into enums, We get a better typechecking, but enums are int's which use more memory then uint8_t's. By 'packing' that struct, we can have the cake and eat it as well.

Apperently GCC/Clang does not handle #pragma packed and Visual studio does not handle __attribute__. These extra ifdef's should do the tricks. (only tested with gcc and clang on linux)

pahole with gcc gives:
struct {
                enum ape_socket_flags flags;             /*   108     1 */
                enum ape_socket_proto proto;             /*   109     1 */
                enum ape_socket_type type;               /*   110     1 */
                enum ape_socket_state state;             /*   111     1 */
        } states;                                        /*   108     4 */

pahole with clang gives:
        struct {
        public:

                enum ape_socket_flags flags;             /*   108     1 */
                enum ape_socket_proto proto;             /*   109     1 */
                enum ape_socket_type type;               /*   110     1 */
                enum ape_socket_state state;             /*   111     1 */
        } states;                                        /*   108     4 */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants