{"action":"created","comment":{"url":"https://api.github.com/repos/citra-emu/citra/pulls/comments/60325846","id":60325846,"diff_hunk":"@@ -403,22 +406,66 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,\n     thread->name = std::move(name);\n     thread->callback_handle = wakeup_callback_handle_table.Create(thread).MoveFrom();\n     thread->owner_process = g_current_process;\n-    thread->tls_index = -1;\n     thread->waitsynch_waited = false;\n \n     // Find the next available TLS index, and mark it as used\n-    auto& used_tls_slots = Kernel::g_current_process->used_tls_slots;\n-    for (unsigned int i = 0; i < used_tls_slots.size(); ++i) {\n-        if (used_tls_slots[i] == false) {\n-            thread->tls_index = i;\n-            used_tls_slots[i] = true;\n-            break;\n+    auto& tls_slots = Kernel::g_current_process->tls_slots;\n+    bool needs_allocation = true;\n+    u32 available_page; // Which allocated page has free space\n+    u8 available_slot; // Which slot within the page is free","path":"src/core/hle/kernel/thread.cpp","position":29,"original_position":29,"commit_id":"919741758bf4d8de7b436cd8839844eb17959a99","original_commit_id":"919741758bf4d8de7b436cd8839844eb17959a99","user":{"login":"lioncash","id":712067,"avatar_url":"https://avatars.githubusercontent.com/u/712067?v=3","gravatar_id":"","url":"https://api.github.com/users/lioncash","html_url":"https://github.com/lioncash","followers_url":"https://api.github.com/users/lioncash/followers","following_url":"https://api.github.com/users/lioncash/following{/other_user}","gists_url":"https://api.github.com/users/lioncash/gists{/gist_id}","starred_url":"https://api.github.com/users/lioncash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lioncash/subscriptions","organizations_url":"https://api.github.com/users/lioncash/orgs","repos_url":"https://api.github.com/users/lioncash/repos","events_url":"https://api.github.com/users/lioncash/events{/privacy}","received_events_url":"https://api.github.com/users/lioncash/received_events","type":"User","site_admin":false},"body":"This should likely be a u32, it's only used as an index.","created_at":"2016-04-19T22:50:09Z","updated_at":"2016-04-19T22:50:09Z","html_url":"https://github.com/citra-emu/citra/pull/1695#discussion_r60325846","pull_request_url":"https://api.github.com/repos/citra-emu/citra/pulls/1695","_links":{"self":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/comments/60325846"},"html":{"href":"https://github.com/citra-emu/citra/pull/1695#discussion_r60325846"},"pull_request":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/1695"}}},"pull_request":{"url":"https://api.github.com/repos/citra-emu/citra/pulls/1695","id":67100776,"html_url":"https://github.com/citra-emu/citra/pull/1695","diff_url":"https://github.com/citra-emu/citra/pull/1695.diff","patch_url":"https://github.com/citra-emu/citra/pull/1695.patch","issue_url":"https://api.github.com/repos/citra-emu/citra/issues/1695","number":1695,"state":"open","locked":false,"title":"Kernel/Threads: Dynamically allocate the TLS region for threads.","user":{"login":"Subv","id":357072,"avatar_url":"https://avatars.githubusercontent.com/u/357072?v=3","gravatar_id":"","url":"https://api.github.com/users/Subv","html_url":"https://github.com/Subv","followers_url":"https://api.github.com/users/Subv/followers","following_url":"https://api.github.com/users/Subv/following{/other_user}","gists_url":"https://api.github.com/users/Subv/gists{/gist_id}","starred_url":"https://api.github.com/users/Subv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Subv/subscriptions","organizations_url":"https://api.github.com/users/Subv/orgs","repos_url":"https://api.github.com/users/Subv/repos","events_url":"https://api.github.com/users/Subv/events{/privacy}","received_events_url":"https://api.github.com/users/Subv/received_events","type":"User","site_admin":false},"body":"The memory pages are allocated from the BASE region as per the real kernel.\r\n\r\nEach thread gets a 0x200-byte area from the 0x1000-sized page, when all 8 thread slots in a single page are used up, the kernel allocates a new page to hold another 8 entries.\r\n\r\nThis is consistent with what the real kernel does.\r\nWith this and #1689, only the VRAM mapping remains in the table of fixed legacy mappings.","created_at":"2016-04-19T22:28:33Z","updated_at":"2016-04-19T22:50:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a8abbb8334504b87d078e4d9bdbc3c3d8a94dbfc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/citra-emu/citra/pulls/1695/commits","review_comments_url":"https://api.github.com/repos/citra-emu/citra/pulls/1695/comments","review_comment_url":"https://api.github.com/repos/citra-emu/citra/pulls/comments{/number}","comments_url":"https://api.github.com/repos/citra-emu/citra/issues/1695/comments","statuses_url":"https://api.github.com/repos/citra-emu/citra/statuses/919741758bf4d8de7b436cd8839844eb17959a99","head":{"label":"Subv:tls_alloc","ref":"tls_alloc","sha":"919741758bf4d8de7b436cd8839844eb17959a99","user":{"login":"Subv","id":357072,"avatar_url":"https://avatars.githubusercontent.com/u/357072?v=3","gravatar_id":"","url":"https://api.github.com/users/Subv","html_url":"https://github.com/Subv","followers_url":"https://api.github.com/users/Subv/followers","following_url":"https://api.github.com/users/Subv/following{/other_user}","gists_url":"https://api.github.com/users/Subv/gists{/gist_id}","starred_url":"https://api.github.com/users/Subv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Subv/subscriptions","organizations_url":"https://api.github.com/users/Subv/orgs","repos_url":"https://api.github.com/users/Subv/repos","events_url":"https://api.github.com/users/Subv/events{/privacy}","received_events_url":"https://api.github.com/users/Subv/received_events","type":"User","site_admin":false},"repo":{"id":22818827,"name":"citra","full_name":"Subv/citra","owner":{"login":"Subv","id":357072,"avatar_url":"https://avatars.githubusercontent.com/u/357072?v=3","gravatar_id":"","url":"https://api.github.com/users/Subv","html_url":"https://github.com/Subv","followers_url":"https://api.github.com/users/Subv/followers","following_url":"https://api.github.com/users/Subv/following{/other_user}","gists_url":"https://api.github.com/users/Subv/gists{/gist_id}","starred_url":"https://api.github.com/users/Subv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Subv/subscriptions","organizations_url":"https://api.github.com/users/Subv/orgs","repos_url":"https://api.github.com/users/Subv/repos","events_url":"https://api.github.com/users/Subv/events{/privacy}","received_events_url":"https://api.github.com/users/Subv/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Subv/citra","description":"Nintendo 3DS emulator/debugger","fork":true,"url":"https://api.github.com/repos/Subv/citra","forks_url":"https://api.github.com/repos/Subv/citra/forks","keys_url":"https://api.github.com/repos/Subv/citra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Subv/citra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Subv/citra/teams","hooks_url":"https://api.github.com/repos/Subv/citra/hooks","issue_events_url":"https://api.github.com/repos/Subv/citra/issues/events{/number}","events_url":"https://api.github.com/repos/Subv/citra/events","assignees_url":"https://api.github.com/repos/Subv/citra/assignees{/user}","branches_url":"https://api.github.com/repos/Subv/citra/branches{/branch}","tags_url":"https://api.github.com/repos/Subv/citra/tags","blobs_url":"https://api.github.com/repos/Subv/citra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Subv/citra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Subv/citra/git/refs{/sha}","trees_url":"https://api.github.com/repos/Subv/citra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Subv/citra/statuses/{sha}","languages_url":"https://api.github.com/repos/Subv/citra/languages","stargazers_url":"https://api.github.com/repos/Subv/citra/stargazers","contributors_url":"https://api.github.com/repos/Subv/citra/contributors","subscribers_url":"https://api.github.com/repos/Subv/citra/subscribers","subscription_url":"https://api.github.com/repos/Subv/citra/subscription","commits_url":"https://api.github.com/repos/Subv/citra/commits{/sha}","git_commits_url":"https://api.github.com/repos/Subv/citra/git/commits{/sha}","comments_url":"https://api.github.com/repos/Subv/citra/comments{/number}","issue_comment_url":"https://api.github.com/repos/Subv/citra/issues/comments{/number}","contents_url":"https://api.github.com/repos/Subv/citra/contents/{+path}","compare_url":"https://api.github.com/repos/Subv/citra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Subv/citra/merges","archive_url":"https://api.github.com/repos/Subv/citra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Subv/citra/downloads","issues_url":"https://api.github.com/repos/Subv/citra/issues{/number}","pulls_url":"https://api.github.com/repos/Subv/citra/pulls{/number}","milestones_url":"https://api.github.com/repos/Subv/citra/milestones{/number}","notifications_url":"https://api.github.com/repos/Subv/citra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Subv/citra/labels{/name}","releases_url":"https://api.github.com/repos/Subv/citra/releases{/id}","deployments_url":"https://api.github.com/repos/Subv/citra/deployments","created_at":"2014-08-10T21:13:43Z","updated_at":"2016-03-05T15:53:20Z","pushed_at":"2016-04-19T22:25:35Z","git_url":"git://github.com/Subv/citra.git","ssh_url":"git@github.com:Subv/citra.git","clone_url":"https://github.com/Subv/citra.git","svn_url":"https://github.com/Subv/citra","homepage":null,"size":13478,"stargazers_count":3,"watchers_count":3,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":0,"forks":5,"open_issues":0,"watchers":3,"default_branch":"master"}},"base":{"label":"citra-emu:master","ref":"master","sha":"6d29c202089e154186e796fd8fe85dae1ea26a1b","user":{"login":"citra-emu","id":7605670,"avatar_url":"https://avatars.githubusercontent.com/u/7605670?v=3","gravatar_id":"","url":"https://api.github.com/users/citra-emu","html_url":"https://github.com/citra-emu","followers_url":"https://api.github.com/users/citra-emu/followers","following_url":"https://api.github.com/users/citra-emu/following{/other_user}","gists_url":"https://api.github.com/users/citra-emu/gists{/gist_id}","starred_url":"https://api.github.com/users/citra-emu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/citra-emu/subscriptions","organizations_url":"https://api.github.com/users/citra-emu/orgs","repos_url":"https://api.github.com/users/citra-emu/repos","events_url":"https://api.github.com/users/citra-emu/events{/privacy}","received_events_url":"https://api.github.com/users/citra-emu/received_events","type":"Organization","site_admin":false},"repo":{"id":19866730,"name":"citra","full_name":"citra-emu/citra","owner":{"login":"citra-emu","id":7605670,"avatar_url":"https://avatars.githubusercontent.com/u/7605670?v=3","gravatar_id":"","url":"https://api.github.com/users/citra-emu","html_url":"https://github.com/citra-emu","followers_url":"https://api.github.com/users/citra-emu/followers","following_url":"https://api.github.com/users/citra-emu/following{/other_user}","gists_url":"https://api.github.com/users/citra-emu/gists{/gist_id}","starred_url":"https://api.github.com/users/citra-emu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/citra-emu/subscriptions","organizations_url":"https://api.github.com/users/citra-emu/orgs","repos_url":"https://api.github.com/users/citra-emu/repos","events_url":"https://api.github.com/users/citra-emu/events{/privacy}","received_events_url":"https://api.github.com/users/citra-emu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/citra-emu/citra","description":"Nintendo 3DS Emulator","fork":false,"url":"https://api.github.com/repos/citra-emu/citra","forks_url":"https://api.github.com/repos/citra-emu/citra/forks","keys_url":"https://api.github.com/repos/citra-emu/citra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/citra-emu/citra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/citra-emu/citra/teams","hooks_url":"https://api.github.com/repos/citra-emu/citra/hooks","issue_events_url":"https://api.github.com/repos/citra-emu/citra/issues/events{/number}","events_url":"https://api.github.com/repos/citra-emu/citra/events","assignees_url":"https://api.github.com/repos/citra-emu/citra/assignees{/user}","branches_url":"https://api.github.com/repos/citra-emu/citra/branches{/branch}","tags_url":"https://api.github.com/repos/citra-emu/citra/tags","blobs_url":"https://api.github.com/repos/citra-emu/citra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/citra-emu/citra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/citra-emu/citra/git/refs{/sha}","trees_url":"https://api.github.com/repos/citra-emu/citra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/citra-emu/citra/statuses/{sha}","languages_url":"https://api.github.com/repos/citra-emu/citra/languages","stargazers_url":"https://api.github.com/repos/citra-emu/citra/stargazers","contributors_url":"https://api.github.com/repos/citra-emu/citra/contributors","subscribers_url":"https://api.github.com/repos/citra-emu/citra/subscribers","subscription_url":"https://api.github.com/repos/citra-emu/citra/subscription","commits_url":"https://api.github.com/repos/citra-emu/citra/commits{/sha}","git_commits_url":"https://api.github.com/repos/citra-emu/citra/git/commits{/sha}","comments_url":"https://api.github.com/repos/citra-emu/citra/comments{/number}","issue_comment_url":"https://api.github.com/repos/citra-emu/citra/issues/comments{/number}","contents_url":"https://api.github.com/repos/citra-emu/citra/contents/{+path}","compare_url":"https://api.github.com/repos/citra-emu/citra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/citra-emu/citra/merges","archive_url":"https://api.github.com/repos/citra-emu/citra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/citra-emu/citra/downloads","issues_url":"https://api.github.com/repos/citra-emu/citra/issues{/number}","pulls_url":"https://api.github.com/repos/citra-emu/citra/pulls{/number}","milestones_url":"https://api.github.com/repos/citra-emu/citra/milestones{/number}","notifications_url":"https://api.github.com/repos/citra-emu/citra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/citra-emu/citra/labels{/name}","releases_url":"https://api.github.com/repos/citra-emu/citra/releases{/id}","deployments_url":"https://api.github.com/repos/citra-emu/citra/deployments","created_at":"2014-05-16T18:33:15Z","updated_at":"2016-04-19T15:36:12Z","pushed_at":"2016-04-19T22:28:33Z","git_url":"git://github.com/citra-emu/citra.git","ssh_url":"git@github.com:citra-emu/citra.git","clone_url":"https://github.com/citra-emu/citra.git","svn_url":"https://github.com/citra-emu/citra","homepage":"https://citra-emu.org","size":19620,"stargazers_count":1715,"watchers_count":1715,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":402,"mirror_url":null,"open_issues_count":210,"forks":402,"open_issues":210,"watchers":1715,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/1695"},"html":{"href":"https://github.com/citra-emu/citra/pull/1695"},"issue":{"href":"https://api.github.com/repos/citra-emu/citra/issues/1695"},"comments":{"href":"https://api.github.com/repos/citra-emu/citra/issues/1695/comments"},"review_comments":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/1695/comments"},"review_comment":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/1695/commits"},"statuses":{"href":"https://api.github.com/repos/citra-emu/citra/statuses/919741758bf4d8de7b436cd8839844eb17959a99"}}}}