{"action":"created","issue":{"url":"https://api.github.com/repos/nix-rust/nix/issues/315","repository_url":"https://api.github.com/repos/nix-rust/nix","labels_url":"https://api.github.com/repos/nix-rust/nix/issues/315/labels{/name}","comments_url":"https://api.github.com/repos/nix-rust/nix/issues/315/comments","events_url":"https://api.github.com/repos/nix-rust/nix/issues/315/events","html_url":"https://github.com/nix-rust/nix/pull/315","id":141057404,"number":315,"title":"Add libc_bitflags convenience macro","user":{"login":"kamalmarhubi","id":50936,"avatar_url":"https://avatars.githubusercontent.com/u/50936?v=3","gravatar_id":"","url":"https://api.github.com/users/kamalmarhubi","html_url":"https://github.com/kamalmarhubi","followers_url":"https://api.github.com/users/kamalmarhubi/followers","following_url":"https://api.github.com/users/kamalmarhubi/following{/other_user}","gists_url":"https://api.github.com/users/kamalmarhubi/gists{/gist_id}","starred_url":"https://api.github.com/users/kamalmarhubi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kamalmarhubi/subscriptions","organizations_url":"https://api.github.com/users/kamalmarhubi/orgs","repos_url":"https://api.github.com/users/kamalmarhubi/repos","events_url":"https://api.github.com/users/kamalmarhubi/events{/privacy}","received_events_url":"https://api.github.com/users/kamalmarhubi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2016-03-15T18:16:51Z","updated_at":"2016-03-16T23:18:14Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nix-rust/nix/pulls/315","html_url":"https://github.com/nix-rust/nix/pull/315","diff_url":"https://github.com/nix-rust/nix/pull/315.diff","patch_url":"https://github.com/nix-rust/nix/pull/315.patch"},"body":"We define many bitflags types with values from the libc crate. Currently\r\nthese look like this:\r\n\r\n    bitflags!{\r\n        flags ProtFlags: libc::c_int {\r\n            const PROT_NONE      = libc::PROT_NONE,\r\n            const PROT_READ      = libc::PROT_READ,\r\n            const PROT_WRITE     = libc::PROT_WRITE,\r\n            const PROT_EXEC      = libc::PROT_EXEC,\r\n            #[cfg(any(target_os = \"linux\", target_os = \"android\"))]\r\n            const PROT_GROWSDOWN = libc::PROT_GROWSDOWN,\r\n            #[cfg(any(target_os = \"linux\", target_os = \"android\"))]\r\n            const PROT_GROWSUP   = libc::PROT_GROWSUP,\r\n        }\r\n    }\r\n\r\nThere's some repetition which is tedious. With the new macro, the above\r\ncan instead be written\r\n\r\n    libc_bitflags!{\r\n        flags ProtFlags: libc::c_int {\r\n            PROT_NONE,\r\n            PROT_READ,\r\n            PROT_WRITE,\r\n            PROT_EXEC,\r\n            #[cfg(any(target_os = \"linux\", target_os = \"android\"))]\r\n            PROT_GROWSDOWN,\r\n            #[cfg(any(target_os = \"linux\", target_os = \"android\"))]\r\n            PROT_GROWSUP,\r\n        }\r\n    }\r\n\r\nThanks to Daniel Keep for the Little Book of Rust Macros, and for\r\nhelping with this macro.\r\n\r\nRefs https://github.com/nix-rust/nix/issues/264\r\n"},"comment":{"url":"https://api.github.com/repos/nix-rust/nix/issues/comments/197599283","html_url":"https://github.com/nix-rust/nix/pull/315#issuecomment-197599283","issue_url":"https://api.github.com/repos/nix-rust/nix/issues/315","id":197599283,"user":{"login":"kamalmarhubi","id":50936,"avatar_url":"https://avatars.githubusercontent.com/u/50936?v=3","gravatar_id":"","url":"https://api.github.com/users/kamalmarhubi","html_url":"https://github.com/kamalmarhubi","followers_url":"https://api.github.com/users/kamalmarhubi/followers","following_url":"https://api.github.com/users/kamalmarhubi/following{/other_user}","gists_url":"https://api.github.com/users/kamalmarhubi/gists{/gist_id}","starred_url":"https://api.github.com/users/kamalmarhubi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kamalmarhubi/subscriptions","organizations_url":"https://api.github.com/users/kamalmarhubi/orgs","repos_url":"https://api.github.com/users/kamalmarhubi/repos","events_url":"https://api.github.com/users/kamalmarhubi/events{/privacy}","received_events_url":"https://api.github.com/users/kamalmarhubi/received_events","type":"User","site_admin":false},"created_at":"2016-03-16T23:18:14Z","updated_at":"2016-03-16T23:18:14Z","body":"@homu retry"}}